Page 1 of 1
Category ID known - how to retrieve path?
Posted: Fri May 09, 2008 5:55 pm
by Don Chambers
From an index.tpl file, I want to get the path to a category's entries (ie,
http://www.mysite.com/categories/2-examplecategory). I already know the category number (ie 2). And it probably has to work regardless of URL rewriting. Is this possible?
I suppose it would be the equivalent of {$entry_category.category_link} in entries.tpl, but this is from index.tpl.
Ideas???
Re: Category ID known - how to retrieve path?
Posted: Fri May 09, 2008 8:44 pm
by garvinhicking
Hi!
I guess you'd need a custom smarty function to wrap around the s9y api "serendipity_categoryURL()" function call to put into your templates' config.inc.php file.
Or you could link to index.php?serendipity[category]=2
Regards,
Garvin
Posted: Fri May 09, 2008 9:06 pm
by Don Chambers
Thanks Garvin - the serendipity_categoryURL() did the trick, along with the expert input of Judebert who I constantly harass anytime I see him using IM!!!

Posted: Tue Sep 30, 2008 8:48 pm
by tpost
*bump*
Can somebody outline what is needed in the config.inc.php file?
I couldn't find any documentation on the serendipity_categoryURL() function.
A link to the documentation could help as well!
Thanks in advance!
Posted: Wed Oct 01, 2008 11:46 am
by garvinhicking
Hi!
The documentation to that function can be found inside include/functions_permalinks.inc.php.
A sample code in the config.inc.php could be:
Code: Select all
function smarty_categoryURL($params, &$smarty) {
$data = serendipity_fetchCategoryInfo($params['id']);
return serendipity_categoryURL($data);
}
$serendipity['smarty']->register_function('smarty_categoryURL', 'smarty_categoryURL');
then you can use this inside your .tpl files:
Code: Select all
<a href="{smarty_categoryURL id=7}">Category #7</a>
HTH
Garvin
Posted: Wed Oct 01, 2008 3:40 pm
by Don Chambers
Garvin's reply looks a lot simpler than what I am using.
Posted: Tue Oct 07, 2008 2:16 am
by tpost
Thanks Garvin!
That helped!