Merging Multiple Relations as params I have the following code where I'm pulling entries related to another entry which works fine. However I also want to limit the entries returned on a category page and thus am merging in a relatedTo: category

However on the category page it is returning all entries related to that category, not limited to the category AND the related entry

{% set myStation = getCookie('myStation') %}
{% set relatedStation = craft.entries.id(myStation) %}


{# set pagination/categories #}
{% set params = { section: 'blog', limit: 6, offset: 1, relatedTo: relatedStation } %}
{% if category is defined %}
  {% set params = params | merge({ relatedTo: category }) %}
{% endif %}

{% set entries = craft.entries(params) %}
{% paginate entries as pageInfo, pageEntries %}


I see the docs includes 'and' (bottom of the page) but I'm not sure how to get that in there using merge. Please advise.
Something like this should work:

{% set myStation = getCookie('myStation') %}
{% set relatedStation = craft.entries.id(myStation) %}

{% set params = { section: 'blog', limit: 6, offset: 1, relatedTo: relatedStation } %}

{% if category is defined %}
    {% set params = params|merge({relatedTo: ['and',
        { element: relatedStation },
        { element: category }
    ]}) %}
{% endif %}

{% set entries = craft.entries(params) %}
{% paginate entries as pageInfo, pageEntries %}


The trick with merge is that it will always replace matching keys that it finds.  So you need to tell it to replace it with the proper and syntax.