Blog module - Two Question.

edited December 2010 in Modules
First question I just figured out.. maybe it helps someone else. To change blog to something else (resources-news in my case)

I added in /application/config/routes.php

$route['resources-news/(:any)'] = 'blog/$1'; Was a little confusing as to *where* that is meant to go..

Second Question
I needed pretty much the exact functionality that categories provides in the blog but for tags. I'm using the blog as more of a resource and news area than a normal blog and people wanted to use tags in there as a way of sub categorizing.

So I duplicated a lot/all of the categories code and swapped it out for tags. Not very pretty but I'm in a rush. Open to better ways!

All is well until clicking a tag and returning the posts for it. Comes up with SQL errors about my tag field in an on clause.

I've hunted it down to the _common_query() in the blog_posts_model(). I can see the how & why it's failing but struggling to find a solution to work with the tags thing and the existing.

I know that's probably hard to follow. I've literally duplicated all the category code and called it tags if that helps.


  • edited 11:34AM
    What's the SQL message say and can you share the how and why it's failing part? Did you add your tags table to the fuel/modules/blog/config/blog.php file (at the bottom)?
  • edited 11:34AM

    Dave - it's Friday here so a few beers in. Will email on Monday.

    Tags table is in the config. I've basically duplicated everything about the categories and swapped out category for tag and the plural.

    I changed the _common_query() from above to also have the same but with tags. The sql error is about an unknown column in the where clause.

    I've cut all the code out that caused issues, will reinstate and zip to you. It required some mods to the Fuel_blog lib too. Not sure if this functionality is really required past my own needs? Would be sweet to not have to hack this again though!
  • edited 11:34AM
    OK... have one for me.
  • edited December 2010
    I sure did!

    I got it figured, was the order I had messed with it. This works:

    $this->db->select($this->_tables['blog_posts'].'.*, '.$this->_tables['blog_users'].'.display_name, CONCAT('.$this->_tables['users'].'.first_name, " ", '.$this->_tables['users'].'.last_name) as author_name', FALSE); $this->db->join($this->_tables['blog_posts_to_categories'], $this->_tables['blog_posts_to_categories'].'.post_id = '.$this->_tables['blog_posts'].'.id', 'left'); $this->db->join($this->_tables['blog_users'], $this->_tables['blog_users'].'.fuel_user_id = '.$this->_tables['blog_posts'].'.author_id', 'left'); $this->db->join($this->_tables['blog_categories'], $this->_tables['blog_categories'].'.id = '.$this->_tables['blog_posts_to_categories'].'.category_id', 'left'); $this->db->join($this->_tables['users'], $this->_tables['users'].'.id = '.$this->_tables['blog_posts'].'.author_id', 'left'); $this->db->join($this->_tables['blog_posts_to_tags'], $this->_tables['blog_posts_to_tags'].'.post_id = '.$this->_tables['blog_posts'].'.id', 'left'); $this->db->join($this->_tables['blog_tags'], $this->_tables['blog_tags'].'.id = '.$this->_tables['blog_posts_to_tags'].'.tag_id', 'left'); $this->db->group_by($this->_tables['blog_posts'].'.id');

    Uh, how do you post formatted code in here? I've added the lines that have the words 'tag(s)' in them. This is in the blog_posts_model _common_query() function.
  • edited December 2010
    I use <pre><code>
Sign In or Register to comment.