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

Category/tag descriptions

Solved by Aaron Dalton View solution

Started by stefan grage 8 years ago · 4 replies · 992 views
8 years ago

Hi Grav supporters,

I have searched around the documentation/forum/web for a way to add tag/category descriptions, and output them in a theme.

Any good hints?

Cheers,

Stefan

8 years ago

This was asked in Slack by @RosemaryOrchard a while ago. I liked the idea and started building something.

I thought I had put it up on Github, but it seems I didn't. I stopped work because I got stuck on a issue with routing, and there was something else I can't quite remember that cast doubt on whether I could make something generally useful. I think I even forgot even to tell Rose, the original poster of the question.

I have something working I can put up for you. It's a proof of concept plugin where you can set term metadata in a folder like user/pages/taxonomies/<term>/term.md and it is exposed to templates like myterm.header.description. I got that working. I wish I could remember why I thought it was doomed ...

Also there's a Github issue in core for the concept, and you could show support perhaps by describing your use case!

8 years ago Solution

I'm spitballing here, but Twig can already see the taxonomy of the page (via page.taxonomy.*), and it can also see variables in the site.yaml config (via config.site.*). Just create a map in your site.yaml that maps tags and categories to descriptions. No plugin required.

👍 1
8 years ago

Yup, that should do it 🙂 I was thinking (as I do!) of a fully fleshed taxonomy with arbitrary term properties. Am particularly interested in one day relating terms to each other, which is actually a big part of what distinguishes a taxonomy from a simple controlled vocab/list. "Taxonomy" is routinely malappropriated in the CMS world!

8 years ago

Indeed true. It should be relatively straightforward to create a plugin that processes a taxonomy definition and then produces various "related links" and stuff from there. I just don't know enough about current practice to know where to start.

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by stuart young, 2 weeks ago
3 251 2 weeks ago
Themes & Styling · by Sebadamus, 3 weeks ago
5 317 3 weeks ago
Themes & Styling · by martynfoster735, 4 weeks ago
1 310 4 weeks ago
Themes & Styling · by Justin Young, 1 month ago
1 348 1 month ago
Themes & Styling · by Slebeig, 2 months ago
4 474 2 months ago