Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Archive

Taxonomy Hierarchy

Started by Muut Archive 11 years ago · 3 replies · 370 views
11 years ago

Looking at a dump of the Grav variable taxonomy and reading through the source code, it appears that there is no concept of taxonomy hierarchy in Grav. That is if a blog is using categories and tags, there doesn't seem to be a data structure that keeps track of which tags are used by which categories. So, if you want to create a menu with the categories as the first level and the tags used in each category in the second, there isn't anything at hand to use.

Does that mean a plug-in would have to traverse the entire site to assemble such an array?

11 years ago

Yes taxonomies are simple independent arrays. If you want something more complex you can build it as a plugin.

11 years ago

Is there a built-in Grav mechanism to traverse the site's pages and query the taxonomy assign to each? Or would that be custom, too?

11 years ago

There are events that are fired while Twig is traversing all the pages:

page-event-hooks

Take a look at the RelatedPages plugin. I think this is a good example of building up some other logic (related pages in this case) and caching those results (for performance) during the page processing within Grav.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1318 9 years ago
Archive · by Muut Archive, 9 years ago
2 915 9 years ago
Archive · by Muut Archive, 9 years ago
2 4044 9 years ago
Archive · by Muut Archive, 9 years ago
1 2920 9 years ago
Archive · by Muut Archive, 9 years ago
3 1104 9 years ago