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.

Themes & Styling

Category/tag descriptions

Solved by Aaron Dalton View solution

Started by stefan grage 8 years ago · 4 replies · 846 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 Pedro M, 2 months ago
4 197 2 months ago
Themes & Styling · by Ian, 2 months ago
3 93 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 454 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 47 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 127 3 months ago