Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Category/tag descriptions

Solved by Aaron Dalton View solution

Started by stefan grage 9 years ago · 4 replies · 1103 views
9 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

9 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!

9 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
9 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!

9 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 FrViPofm, 4 weeks ago
4 473 2 weeks ago
Themes & Styling · by johan thomas, 5 years ago
1 800 3 weeks ago
Themes & Styling · by stuart young, 2 months ago
3 659 2 months ago
Themes & Styling · by Sebadamus, 3 months ago
5 679 2 months ago
Themes & Styling · by martynfoster735, 3 months ago
1 642 3 months ago