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

Syndication buttons and url

Started by Muut Archive 11 years ago · 5 replies · 301 views
11 years ago

I use GRAV as a blog. No problem with the feed plugin and syndication buttons on the page with the list of articles. But the url of these buttons are bad for all other pages: page with a complete article, contact page, author's page,... I think the problem is the variable {{ feed_url }}. I don't find where this vaiable is created or assigned in the feed plugin.

Could you help to find this variable?

At this time, I modified the file "sidebar.html.twig" in the template, like this :

TWIG
    {% if feed_url != 'blog' %}
        {% set feed_url = 'blog' %}
    {% endif %}
<div class="sidebar-content syndicate">
    <h4>Syndicate</h4>
    <a class="button" href="{{ base_url_relative }}/{{ feed_url }}.atom"><i class="fa fa-rss-square"></i> Atom 1.0</a>
    <a class="button" href="{{ base_url_relative }}/{{ feed_url }}.rss"><i class="fa fa-rss-square"></i> RSS</a>
{% endif %}

I know this code is bad, but it works fine.
Thx

11 years ago

Have you updated to the very latest version of the plugins? and if you based your theme on Antimatter, had a look at latest version of that also?

A month or so back, I addressed this very problem. Basically I calculate a different base_url local variable in blog.html.twig and item.html.twig so that the links for these plugins is correct on each page.

BTW, your solution will work too. However, your just setting feed_url to blog every time, so not sure the need for the if()

11 years ago

Thx for your answer. I updated feed plugin to 1.3.1 and antimatter to 1.3.0. I think it is the last versions.

I will look in the 2 twig files why I have this problem. I will post here my results tomorrow :-)

11 years ago

I found the problem for the pages of blog. I forgot to update item.html.twig. Shame on me! ^^

But how can I address feed_urlfor the pages out of the blog (i.e. contact page)?

At this time I replaced:

TWIG
        {% set feed_url = base_url~'/'~page.parent.slug %}
    {% endif  %}

by

TWIG
        {% set feed_url = base_url~'/'~page.header.feed %}
    {% endif  %}

in the twig files out of the blog and where page.header.feed is addressed in the header of the md file.

Do you have a better way to do that, without a new line in the header of md files?
Thx

11 years ago

If you need to access from various pages you could set a site wide global variable in you site.yaml file and reference that. My changes were an attempt to make the theme not require a configure option like that, but if it works better for your use case there is nothing wrong with it.

11 years ago

OK, it seems to me it was the solution too, but I am not an expert with GRAV today. Thank you very much for your confirmation.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1318 9 years ago
Archive · by Muut Archive, 9 years ago
2 915 9 years ago
Archive · by Muut Archive, 9 years ago
2 4044 9 years ago
Archive · by Muut Archive, 9 years ago
1 2920 9 years ago
Archive · by Muut Archive, 9 years ago
3 1104 9 years ago