getgrav / grav-plugin-taxonomylist

Grav TaxonomyList Plugin
https://getgrav.org
MIT License
25 stars 14 forks source link

Not working + missing example. Possible workaround to both issues. #14

Closed fabrizioT closed 7 years ago

fabrizioT commented 8 years ago

I've spent some time in figuring how to get this working, as no example was given ... Unless i'm wrong i guess you are supposed to traverse the taxonomy list from Twig via some code like:

{% for name,count in taxonomylist.category %} taxonomy name:{{name}} - number of posts:({{count}}) {% endfor %}

However i was unable to get the list populated. I do think function onTwigSiteVariables() within taxonomylist.php is broken / uncomplete.

Seems to me it simply lacks the proper getter call, so generated list is always empty. The plugin works when i add this (ugly) call at the bottom of onTwigSiteVariables() function:

$twig->twig_vars['taxonomylist'] = $twig->twig_vars['taxonomylist']->get();

I stand corrected.

fabrizioT commented 8 years ago

Nevermind. Getter should be explicitly called and the plugin will work straight out-of-the-box.

Found a working example here: [removed for spam link]

`{% set taxlist = taxonomylist.get() %} {% if taxlist %} {% for tax,value in taxlist['category'] %}

  • {{ tax|capitalize }}
  • {% endfor %}

    {% endif %}`

    onetrev commented 5 years ago

    The link above goes to a SPAM site. It should be removed immediately.

    I'm not sure who is best to contact for this, so I'm just adding @rhukster and @mahagr since I see you guys as most active in the repo.

    MakaryGo commented 4 years ago

    The link above goes to a SPAM site. It should be removed immediately.

    That's true, however I did manage to find original content on Wayback Machine : https://web.archive.org/web/20180207164318/http://diblas.net/blog/add-the-posts-categories-to-the-blog-navigation-menu-powered-by-grav-cms#

    ricardo118 commented 4 years ago

    removed the spam link