Greetings, fellow gravers,
Warning: noob question
I’m learning Grav from a design background, and I’m frankly amazed at what I’ve been able to do just by just testing and trying for a couple of days.
I’m using a bit of twig on a modular page to display taxonomy values from several modules:
{% set taxlist = page.taxonomy %}
{% for tax,value in taxlist|sort %}
{% if value is not empty %}
{% for v in value %}
{{ v|replace('-', ' ') }}
<br>{% if not loop.last %},{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
The modular page is a list of projects. So for each module you have the title of the project, and then several bits of informations (clients and so on). The <br> is so you return to the next line after each value, like so:
Nice Project
Shop design
Corporate, Inc.
It’s just what I want, until there are 2 values for a field, such as:
Nice Project
Shop Design,
Interior Design
Corporate Inc.
I’d prefer values from the same category to be displayed on one line:
Nice Project
Shop Design, Interior Design
Corporate Inc.
Would there be a way to specify this? Such as, if values are from the same category, insert a comma and next value is displayed on the same line; if they aren’t, insert a <br> (or a <li> item, or anything);
Alternatively, would there be a way to independently select values for fields ‘Project Type’ and ‘Client’, for example?
And which method would you find better/more efficient?
Cheers,