Kevin's Papers

All my technical papers in one place!
1 minute reading time (265 words)

Filter all Articles Within Nested Categories in Joomla 1.7

It has been a real pain to work with the articles that are nested inside sub categories in joomla 1.7. Why this was overlooked is still a mystery but one we should expect with this new nested category structure. The problem is when you filter a category in the article viewer, the only articles that currently show up are those that are in the selected category. If you want to see articles that are nested in the sub categories in the one you are viewing you have to select each category one at a time to see the other articles.

There is a core hack that works to show all articles inside of a category and all the articles that are in sub categories. We need to open the articles.php file that is found in administrator/components/com_content/models folder. Navigate to line 190 or if your editor does not support line count, look for //Filter by a single or group of categories. code hint.

NOTE: Dont be confused as there are two files (article.php) & (articles.php) so make sure you choose the right one (articles.php)!

 

From here we need to find the following bit of code:

 

$query->where('c.path like (select concat(path,"%") from #__categories where id='.(int)

 

And replace that line with this:

 

$query->where('c.path like (select concat(path,"%") from #__categories where id='.(int) $categoryId.')');

 

Once that is done when you select a category in the article manager all the articles in that category and all categories that are nested within it will now display.

 

Thanks to Per Yngve Berg for sharing this code with us;)

LINK

Social Branding Part 2
Social Branding Part 1