Taxonomy list in drop-down

Excuse me if I am using this wrong. But I have a church website I am building which has sermon categories that will be defined by whoever the author is that creates the post (blog page).

I have search setup but also want to provide drop-downs to sort by pastor and series. The code below will grab all of the sermon series values, but many of these have identical values.

<select>
   {% for i in page.children %}
      {% for series in i.taxonomy.series %}
      <option>{{series}}</option>
      {% endfor %}
   {% endfor %}
</select>

If not obvious, I would like each sermon only to display once, and then have that selection take you to a results page with all sermons under that value (similar to how clicking a taxonomy tag will sort results to that tag). Am I overcomplicating this or is there a solution that I have overlooked?

BTW, I have looked at the taxonomy list plugin and a tag cloud is not a feasible solution due to the amount of information.

Newbie here, but wondered if that would help you.

My thought was that if what the user says is true, and you need to process php, maybee you should create a plugin, which I think can use full php and are in the grav docs.

(Still learning so sorry if that’s no use).

That was it!

Here is the code in case anyone else runs into this.

{% set allseries = [] %}
{% for i in page.children %}
  {% for series in i.taxonomy.series %}
    {% if series not in allseries %}
    {% set allseries = allseries|merge([series]) %}
    {% endif %}
  {% endfor %}
{% endfor %}
<select>
  {% for i in allseries %}
    <option>{{i}}</option>
  {% endfor %}
</select>

If anyone knows a better way, please share!

Alternatively you can perform this logic in the PHP of the plugin and set the resulting array to variable that your twig can simply loop over.

Either way works though :slight_smile: