The last option's description for the freetags sidebar plugin states: "If set the template is used to render the tag sidebar. In the template there is a variable <tags> available which contains the list of tags in the format <tagName> => array(href => <tagLink>, count => <tagCount>)"
Does anyone have an example for how to use this? I don't get it at all.
YL
Sidebar template freetags
Re: Sidebar template freetags
I dont have an example at hand, but the code says:
So there is a smarty-variable $tags you can iterate over. Every tag in tags is an array with the name and the count, so something like
should work.
Code: Select all
arsort($tags);
$tagsWithLinks = array();
foreach ($tags as $tag => $count) {
$tagsWithLinks[$tag] = array(
'count' => $count,
'href' => $taglink . serendipity_event_freetag::makeUrlTag($tag),
);
}
$serendipity['smarty']->assign('tags', $tagsWithLinks);
$template = serendipity_getTemplateFile($template, 'serendipityPath');
$serendipity['smarty']->display($template);
Code: Select all
{foreach from="tags" key="tagname" item="tag"}
<li><a href="$tag.href">$tagname ($tag.count)</a></li>
{/foreach}
Re: Sidebar template freetags
Nope, no output at all.onli wrote:something likeshould work.Code: Select all
{foreach from="tags" key="tagname" item="tag"} <li><a href="$tag.href">$tagname ($tag.count)</a></li> {/foreach}
Might be related to the fact that I don't have the plugin sitting in the sidebar but do emit it on the archives page using serendipity_showPlugin, I guess. Hmm. Bummer.
YL
Re: Sidebar template freetags
The relevant code is in serendipity_event_freetag, the sidebar-plugin just toggles the option. This will only work if the event_freetag-plugin is executed.
And i'm not sure with the syntax of the smarty-code, regard it more as pseudo-code probably needing correction.
And i'm not sure with the syntax of the smarty-code, regard it more as pseudo-code probably needing correction.
Re: Sidebar template freetags
The extended tpl is working with,
maybe you need to use same.
Or just have a look what {$tags|print_r} says.
Code: Select all
{foreach from=$entry.freetag.tags.tags item="tag"}
{$tag}
{/foreach}
Or just have a look what {$tags|print_r} says.
Regards,
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Re: Sidebar template freetags
That's a different part of the plugin. That's the code for one entry and not referenced by the option of the sidebar-plugin. Probably not what is wanted (a list of all tags, i thought).maybe you need to use same.
Good idea.Or just have a look what {$tags|print_r} says.
Re: Sidebar template freetags
Yepp, I wanted to say ...something similar (like $tags.tag)
Regards,
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Re: Sidebar template freetags
Ah, ok. That's of course possible, though the code seems to inidcate otherwise.