List/Link Global Categories in Sidebar

List/Link Global Categories in Sidebar

Postby lolotrgeek on Tue Aug 23, 2011 7:48 pm

Hello,
I have searched the forums trying to find a way to list and link the global categories in the sidebar so that when one of the global categories is clicked it brings up a list of all the articles in that global category (similar to the existing article category system). Here is the code that I have attempted to use in the "footer.template" without success:

Code: Select all
   
<ul>                        
{foreach from=$globalcategories item=globalCategory}
<li><a title="{$globalCategory->getName()}" href="{$url->categoryLink($globalCategory)}">{$globalCategory->getName()} <abbr title="{$globalCategory->getNumPublishedArticles()} {$locale->tr("posts")}">[{$globalCategory->getNumArticles()}]</abbr></a></li>
{/foreach}
</ul>   


Any help/suggestions are appreciated,

Thank you
lolotrgeek
 
Posts: 1
Joined: Tue Aug 23, 2011 11:55 am
LifeType Version: 1.2

Re: List/Link Global Categories in Sidebar

Postby jondaley on Fri Sep 02, 2011 11:35 am

sorry that i didn't see this before.

You probably should take a look at the categorybrowser plugin and write one that is similar. You could also do it without writing SQL by using the dao classes, and arguably, that would be a better way.

For that, you should probably look at the summary.php code (or rather the class/summary/* code that references the global categories.

The function to get a list of all categories is here:
class/dao/globalarticlecategories.class.php: getGlobalArticleCategories()

Once you have the category ID, then you can use the class/dao/articlecategory.class.php function on that to get the articles that you care about.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch


Return to Templates

cron