The Serendipity Handbook

You can now read the (german) handbook here: PDF - https://github.com/s9y/Book (LaTeX source).

Forum-Information

Before posting about errors, make sure that the answer cannot already be found in our FAQ or by searching this forum!
Posting is restricted to registered users (registering is free and simple!) due to recent spam attacks. When having trouble with this board, contact garvin(-at)s9y(-dot)org.

Board index Plugins Sidebar template freetags

Creating and modifying plugins.
User avatar
yellowled
Regular
 
Posts: 5615
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany

Postby yellowled » Sun Dec 11, 2011 2:46 pm

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

User avatar
onli
Regular
 
Posts: 1410
Joined: Tue Sep 09, 2008 10:04 pm

Postby onli » Sun Dec 11, 2011 3:31 pm

I dont have an example at hand, but the code says:
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);

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
Code: Select all
{foreach from="tags" key="tagname" item="tag"}
    <li><a href="$tag.href">$tagname ($tag.count)</a></li>
{/foreach}

should work.

User avatar
yellowled
Regular
 
Posts: 5615
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany

Postby yellowled » Sun Dec 11, 2011 3:55 pm

onli wrote:something like
Code: Select all
{foreach from="tags" key="tagname" item="tag"}
    <li><a href="$tag.href">$tagname ($tag.count)</a></li>
{/foreach}

should work.

Nope, no output at all.

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

User avatar
onli
Regular
 
Posts: 1410
Joined: Tue Sep 09, 2008 10:04 pm

Postby onli » Sun Dec 11, 2011 4:14 pm

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.

User avatar
Timbalu
Regular
 
Posts: 3848
Joined: Sun May 02, 2004 3:04 pm

Postby Timbalu » Sun Dec 11, 2011 4:49 pm

The extended tpl is working with,
Code: Select all
         {foreach from=$entry.freetag.tags.tags item="tag"}
            {$tag}
         {/foreach}
maybe you need to use same.
Or just have a look what {$tags|print_r} says.
Regards,
Ian

User avatar
onli
Regular
 
Posts: 1410
Joined: Tue Sep 09, 2008 10:04 pm

Postby onli » Sun Dec 11, 2011 4:52 pm

maybe you need to use same.

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).
Or just have a look what {$tags|print_r} says.

Good idea.

User avatar
Timbalu
Regular
 
Posts: 3848
Joined: Sun May 02, 2004 3:04 pm

Postby Timbalu » Sun Dec 11, 2011 4:57 pm

Yepp, I wanted to say ...something similar (like $tags.tag) ;-)
Regards,
Ian

User avatar
onli
Regular
 
Posts: 1410
Joined: Tue Sep 09, 2008 10:04 pm

Postby onli » Sun Dec 11, 2011 7:07 pm

Ah, ok. That's of course possible, though the code seems to inidcate otherwise.



Return to Plugins

Who is online

Users browsing this forum: No registered users and 2 guests