Replace field value while grouping

Hi there,

I´m developing a simple order form. The items that go into the form have a category tag in their content files. I build the list of articles with a loop and group by category tag:

  • Category A
    – Article 1
    – Article 2
  • Category B
    – Article 3
    – Article 4

Now, my client would like to have more text/different sublines instead of simply showing the categories:

  • Our offerings in category A
    – Article 1
    – Article 2
  • More offerings for people in need of B
    – Article 3
    – Article 4

I know, I could simply replace the tags in the content files with the sentences, the client requires. But there should be a more elegant, Kirby-like solution.

Any ideas?

There are several ways to handle this:

Option 1: Create a structure field for the categories, with a field for the category name and a field for what should be displayed when the category is shown.

Option 2: Use a category map in config options with a set of key/value pairs.

Option 3: In a multi-language side, you can use the translation variables for this purpose.

Option 1 is the most versatile and dynamic variant in my opinion.

How are categories assigned at the moment?

Hi Sonja,

ahh, that´s it! Thank you very much, I´ll choose option 2.