so i filter some entries via the url parameters... that works fine. But if i load more entries (based on the category parameter), the result includes also all other entries with other categories... but of course i just wanna load more entries based on that one category parameter... any ideas? :)
{% set category = craft.app.request.getParam('category') %}
{% set organisation = craft.app.request.getParam('organisation') %}
{% set topic = craft.app.request.getParam('topic') %}
{% set organisationCat = organisation ? craft.categories.group('organisation').slug(organisation).one() %}
{% set categoryCat = category ? craft.categories.group('category').slug(category).one() %}
{% set topicCat = topic ? craft.categories.group('topic').slug(topic).one() %}
{% set organisationParam = organisationCat ? {targetElement: organisationCat} %}
{% set categoryParam = categoryCat ? {targetElement: categoryCat} %}
{% set topicParam = topicCat ? {targetElement: topicCat} %}
{% set relationParams = [organisationParam, categoryParam, topicParam]|filter %}
{% set topicsEntries = craft.entries({
section: 'topics',
relatedTo: relationParams ? ['and']|merge(relationParams) : null,
}) %}
{% set offset = offset ?? 0 %}
{% set limit = 3 %}
{% set allTopicsEntries = topicsEntries.offset(offset).limit(limit) %}
{% set allTopicsOutputEntries = allTopicsEntries.all() %}
{# Loop and output #}
{% for topic in allTopicsOutputEntries %}
<div class="grid-item">
{% if topic.topicLink is defined and topic.topicLink|length %}
<a class="card-topic" href="{{topic.topicLink}}" target="_blank" rel=”noopener noreferrer”>
<div class="card-topic__wrapper">
{% if topic.catTopic is defined and topic.catTopic|length %}
<span class="card-topic__toptitle">{{topic.catTopic.one().title}}</span>
{% endif %}
{% if topic.topicTitle is defined and topic.topicTitle %}
<h3 class="card-topic__title">{{topic.topicTitle}}</h3>
{% else %}
<h3 class="card-topic__title">{{topic.title}}</h3>
{% endif %}
{% if topic.topicText is defined and topic.topicText|length %}
<div class="card-topic__text">
<p>{{topic.topicText}}</p>
</div>
{% endif %}
<div class="card-topic__button">
<span class="button-circle button-circle-theme-bright">
<span class="button-circle__icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 12" style="enable-background:new 0 0 14 12" xml:space="preserve"><path d="m7 11 5-5-5-5" style="fill:none;stroke:#1a0d3d;stroke-width:2;stroke-linecap:round"/><path d="M1 5c-.6 0-1 .4-1 1s.4 1 1 1V5zm11 0H1v2h11V5z" style="fill:#1a0d3d"/></svg>
</span>
</span>
</div>
</div>
</a>
{% endif %}
</div>
{% endfor %}
{# If the total entry count is greater than the number that has been displayed#}
{% if allTopicsEntries.count() > offset + allTopicsOutputEntries|length %}
{# Increments `offset` by the value of `limit` and swaps itself out on click #}
<div sprig s-val:offset="{{ offset + limit }}" s-target="this" s-swap="outerHTML" class="news-footer">
<button class="button button-theme-transparent">
<span class="button-title">Mehr anzeigen</span>
</button>
</div>
{% endif %}