How can I display the contents of the blog page text for the first page only?

Hello, on the blog page there are more than 25 child pages, and of course when you open the blog appears pagination. But since the blog page has a description (that is, the text in the body of the blog page itself), this text is repeated on each page of the pagination. How can I get this text to appear on the first page of the blog?

Looking at the pagination buttons at the bottom of a blog, it is clear that the pagination plugin knows if it is at the beginning, or end, of the collection of blog pages.

When digging into the plugin’s template ‘/templates/pagination.html.twig’, we can see the plugin uses the following to determine if it is NOT at the beginning of the collection:

{% if pagination.hasPrev %}

where ‘pagination’ is defined at the top as:

{% set pagination = pagination|default(page.collection.params.pagination) %}

Looking at the code of the plugin, it seems to extend the ‘params’ property of a collection. It adds a ‘pagination’ property, which provides methods like ‘hasPrev()’ and ‘hasNext()’.

Solution:
You could try if the following works for you. Add these lines to template ‘blog.html.twig’:

{% if not page.collection.params.pagination.hasPrev %}
    <h1>The text I only want to show on page 1</h1>
{% endif %}

I don’t know for Helium/Gantry, but is does work for Quark… :wink:

1 Like

Perfect solution! Many thanks, everything turned out!