Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

issues when listing post in blog module

edited September 2016 in Modules
I was having some odd results in the backend of my blog module install, in the posts list view. I'm not sure if it qualifies as bug but I'm think it worth to share it.
When I first try the module I added a second fuel user and I made an author associated to it. After that I made a second author associated to the admin account. So somehow the id's where crossed, fuel_id 1 was linked to author_id 2, and viceversa fuel_id 2 associated to author_id 1.
At the moment of listing the posts I was only getting the posts associated to id=1, because of a default filter in blog option. But when I looked at it closer I realize that I was getting the posts of author_id=1, but with the author name of fuel_id=1. So in actually was mixing the ownership of the posts in the list.

I changed this join condition:
$this->db->join($this->_tables['fuel_users'], $this->_tables['blog_posts'].'.author_id = '.$this->_tables['fuel_users'].'.id', 'left');

for this one:
$this->db->join($this->_tables['fuel_users'], $this->_tables['blog_users'].'.fuel_user_id = '.$this->_tables['fuel_users'].'.id', 'left');

That solved the mixed ownership issue (I think actually that is better to associate the fuel user to the blog user and not directly to the post).
But then I was still getting the list only for user_id=1, no matter with which account I was logged in. As I needed to be able to see all the post in the list, I just removed the filter in the blog options file, but is possible that there is some problem there too.

Anyway, after doing all that, I made some modification to the data of one of the authors or the accounts, don't remember exactly. The curious thing is when I looked th DB again, the crossed id of accounts and authors where now fixed, fuel_user=1 had author_id=1 and the same for the rest. I guess the system reordered them by itself, so that's why I cannot say there's a bug there, maybe I was touching something that I shouldn't ;)

Hope it helps!

Comments

  • edited 3:00AM
    By the way.. is any easy way to configure the locale? or to set the language for dates at least? I had a lot of troubles in dates inputs. I had to convert them from spanish format to english or DB format depending the case, to pass validation.
    Where is the blog module doing that validation? The only way I found was to convert it in the on_before_post method, 'cause it was arriving already filtered to on_before_clean one
  • edited 3:00AM
    What version of the blog module are you using?

    The fuel/application/config/MY_config.php file has a date_format value which will change the display formatting in the form. On the saving side, the MY_Model::clean function converts dates using the english_date_to_db_format function.
  • edited 3:00AM
    Blog version:
    define('BLOG_VERSION', '1.1');

    I was able to change the way that dates are displayed in forms. The main problem was that in the moment of saving to DB, the spanish format of the date was taken as invalid and not converted to DB format. I needed to do a preconversion from spanish to english. It was easy in simple modules, just added a line calling to a method in on_before_clean. But in the blog_post_model it was somehow validated before and was arriving to on_before_clean already as invalid (actually it was converted to 31/12/1969).
    The only way I found was to do the convertion from spanish to english in on_before_post
Sign In or Register to comment.