I want to generate a list of events that are related to a specific festival and that are related to a specific category. This goal sits alongside some others that are inspiring me to attempt this in a single template and to do so via building params that are then passed to Craft entries tag. Using Craft 3.
First the base params - these return a fine result.
{# Set base criteria for event query #}
{% set params = {
section : 'events',
orderBy : 'eventStartDateTime asc',
relatedTo: [
{ element: entry.id }
],
limit: null
} %}
Next here are the params to try and get the events associated with a specific festival entry and that are related to a specific category.
{# Segment 4 is about categories #}
{% if craft.app.request.getSegment(4) %}
{# segment 4 is the category slug #}
{% set cat = craft.app.request.getSegment(4) %}
{% set relationParam = {
relatedTo: ['and',
{ targetElement: cat },
{ element: entry.id }
]
}%}
{% set params = params|merge(relationParam) %}
{% endif %}
What I am seeing in this second scenario is I am not getting results filtered by the category. Feel like I am close but missing something, likely fundamental.