How to have rss per tag?

Hi;

I know this subject was already mentionned here
Continuing the discussion from RSS per tag:

but I wonder if it was finally released ?

1 Like

Hi @jodumont Had a look at the feed plugin for you…

TL;DR: Solution is at the bottom.

Rationale:
NB. I used the Quark based ‘Blog Site’ skeleton.

It seems the issue is not in the feed plugin itself. The plugin merely creates a list based on the collection of the blog page. That means that if parameters (e.g. localhost/site-blog/tag:night) of the blog are being removed form the url, the plugin will always show all blog items.

The source of the problem can be found in Quarks template ‘/partials/sidebar.html.twig’, which creates the Atom, RSS, JSON buttons.

<a class="btn" href="{{ feed_url }}.atom"><i class="fa fa-rss-square"></i> Atom 1.0</a>
<a class="btn" href="{{ feed_url }}.rss"><i class="fa fa-rss-square"></i> RSS</a>
{% if config.plugins.feed.enable_json_feed %}<a class="btn" href="{{ feed_url }}.json"><i class="fa fa-rss-square"></i> JSON</a>{% endif %}

The variable ‘feed_url’ is the interesting part here. At the top of the template the ‘feed_url’ is created… and it drops the parameters…

Solution:
In your inherited theme, edit the template ‘sidebar.html.twig’ as follows:
Replace line:

{% set feed_url = blog.url == '/' or blog.url == base_url_relative ? (base_url_relative~'/'~blog.slug) : blog.url %}

by:

{% if uri.params %}
    {# the uri.uri contains the url + parameters #}
    {% set feed_url = blog.url == '/' or blog.url == base_url_relative ? (uri.uri~'/'~blog.slug) : blog.url %}
{% else %}
    {# keep original logic #}
    {% set feed_url = blog.url == '/' or blog.url == base_url_relative ? (base_url_relative~'/'~blog.slug) : blog.url %}
{% endif %}

The ‘feed_url’ creation might have room for optimisation, but it works…