Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Plugins

How to have rss per tag?

Started by JOduMonT 8 years ago · 1 replies · 780 views
8 years ago

Hi;

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

@Muut:
plugin and put into our Plugin repository

but I wonder if it was finally released ?

👍 1
8 years ago

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.

TWIG
<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:

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

by:

TWIG
{% 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...

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Rene, 1 week ago
2 49 1 week ago
Plugins · by Xavier, 4 weeks ago
2 57 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1184 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 50 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 75 2 months ago