Category Count – Final
This mod will list counts in your categories.tpl file that shows in your sidebar.
I have ONLY tested this in 9.8.2
Find in libs/dbtree.php:
$row = $db->get_row($sql);
if(!$row){
die('There is a problem with the categories table. Error CA:001.');
}
}
after, add:
$catcount = $db->get_results("SELECT COUNT(l.link_category) as catcount, c.category_id FROM pligg_categories c LEFT JOIN pligg_links l ON c.category_id = l.link_category GROUP BY c.category_id"); # query to count the link_category
find,
foreach($result as $row){
if (count($right)>0) {
// check if we should remove a node from the stack
while ($right[count($right)-1]< $row->rgt) {
if (array_pop($right) == NULL) {
break; // We've reached the top of the category chain
}
}
}
after, add
foreach ($catcount as $v) # loop through the result and find the id that matches, if found then this is the associated category count
{
if ($v->category_id == $row->category__auto_id) { # found it, store it and break
$array[$i]['catcount'] = $v->catcount;
break;
}
in templates/yget/sidebar_modules/categories.tpl
find and add the parts bolded and italicized:
{if $pagename eq “published”}
{$cat_array[thecat].name}{if $cat_array[thecat].parent neq 0} ({$cat_array[thecat].catcount}) {/if}
{else}
{$cat_array[thecat].name}{if $cat_array[thecat].parent neq 0} ({$cat_array[thecat].catcount}) {/if}
{/if}
go to libs/smartyvariables and add:
// show count of category
#$catcount = $db->get_results('SELECT COUNT(l.link_category) as catcount, c.category_id FROM pligg_categories c LEFT JOIN pligg_links l ON c.category_id = l.link_category GROUP BY c.category_id');
#$catcount = $db->get_var('SELECT a1.Link_Category , b1.Category_Name , count( * ) TotPerCategory ' . ' from pligg_links a1 , pligg_categories b1 ' . ' where a1.Link_Category = b1.Category_ID ' . ' group by a1.Link_Category , b1.Category_Name ' . ' order by b1.Category_Name; ');
#$main_smarty->assign('catcount', $catcount);
Thats it.
Any issues post them here.
Geoserv.
Backup all files prior to applying this additions. I guarantee nothing and you are applying at your own risk.
Related Search:
- categories count
- catogory count
- catorgory count









Pingback: Google - Pligg Forum
Pingback: 3T Group - Diary of development » Blog Archive » Error CA:001 of Pligg