Pagination of translated pages not working properly

Hi,
I’d like to fix this issue we’re having on our company’s site.
If you compare the Italian (original) blog page with English blog page, you’ll see that pagination on the English blog is not correct. There are pages with 1 or 2 articles, and others with 6-8 articles.

Apparently, the blog page uses the Italian pagination and then simply shows empty slots if an Italian article hasn’t been translated to English.

This is the code of blog.html.twig. Any help will be appreciated.

{% extends 'partials/base.html.twig' %}

{% block content %}
  {% include 'partials/banner2.html.twig' %}
  
<!-- Search box -->
<div class="container">
	<div class="row">
		<div class="col-lg-12 col-md-12">
			{{ content|raw }}
        </div>
    </div>
<div class="row">
<div class="col-lg-12 col-md-12">
{% include 'partials/simplesearch_searchbox.html.twig' %}
</div>
</div>
</div>
  <!-- ============================ Blog Grid Start ================================== -->
  {% set collection = page.collection() %}
  <section>
  	<div class="container">
  		<div class="row">
        {% for child in collection %}
            {% if child.language == grav.language.getLanguage %}
  			<!-- Single Blog Grid -->
            <div class="col-lg-6 col-md-6">
  				<div class="blog-grid-wrap mb-4">
  					<div class="blog-grid-thumb">
  						<a href="{{ child.url }}">
                <img src="{{ child.media.images|first.url() }}" class="img-responsive" alt="" />
              </a>
  						<div class="bg-cat-info">
  							<h6>{% for cat in child.header.taxonomy.category %}{{ cat }}{% if not loop.last %},{% endif %} {% endfor %}</h6>
  							<span>{{ child.header.date|date('d') }} {{ 'GRAV.MONTHS_OF_THE_YEAR'|ta(child.header.date|date('n') - 1) }} {{ child.header.date|date('Y') }}</span>
  						</div>
  					</div>
  					<div class="blog-grid-content">
  						<h4 class="cnt-gb-title">
                <a href="{{ child.url }}">{{ child.title }}</a>
              </h4>
  						<p>{{ child.summary(110)|striptags }}</p>
  					</div>
  					<div class="blog-grid-meta">
  						<div class="gb-info-author">
  							<p><i class="fa fa-user-circle-o"></i> {% for author in child.taxonomy.author %}{{ author }}{% if not loop.last %},{% endif %} {% endfor %} <span class="reading-time"> <i class="fa fa-clock-o"></i> {{ child.content|readingtime }}</span></p>
						</div>
  					</div>
  				</div>
  			</div>
            {% endif %}
        {% endfor %}
  		</div>
  		
  		<div class="row">
  			<div class="col-md-12">
  				<div class="bs-example">
            {% include 'partials/pagination.html.twig' with {'base_url':page.url, 'pagination':collection.params.pagination} %}
  				</div>
  			</div>
  		</div>
  		
  	</div>
  </section>
  <div class="clearfix"></div>
  <!-- ============================ Blog Grid End ================================== -->
{% endblock %}

I’d like to have 8 articles on each page, regardless of the language. So, page 1 of the English blog should show the latest 8 English articles, even though these articles don’t match the Italian ones.

I hope it’s clear. If it isn’t, I’ll be happy to explain further.

Thanks in advance,

Marco

Do frontmatters of both blog[.it]?.md and blog.en.md match for the list part?

Yes, they do (except description and metadata values):

---
title: Blog
content:
    items: '@self.children'
    order:
        by: date
        dir: desc
    limit: 8
    pagination: true
description: '“Under the Hood”, Qabiria’s blog dedicated to translation, copywriting, business writing, effective writing and internationalization. Read all the posts.'
metadata:
    keywords: translation blog, blog on translation, blog on internationalisation, blog on business writing, blog on writing, blog on copywriting
---

@Karmalakas , you hinting at the frontmatter made me think that the issue was indeed related to the way Grav creates the collection. I’ve found a thread on Github (Pages: Collection for secondary language contains dummy items for untranslated default language · Issue #2985 · getgrav/grav · GitHub) that suggested to add

  content_fallback:
    en: en
    it: it
    es: es

to the system.yaml configuration file.
That did the trick. I still have to check the rest of the site, to be 100% sure that this configuration hasn’t broken anything else…

Thanks!

Marco

1 Like

Sorry, I spoke too soon. I now see the same wrong behaviour. Not sure if it has to do with cache… I’ll try on other computer and report back here…

ok, here’s my findings: for reasons that I don’t know, if you go to the backend and access the Configuration > Language tab, Grav doesn’t allow you to set fallback from a language into the same language. So, en: en becomes en: en,es,it, which causes the above error.
However, if I leave the backend page and manually edit system.yaml, then I can set the fallback configuration as above and the pagination is correct.

I think there is another bug or misbehaviour on the backend/admin page, because Grav is repeatedly asking me that there are “unsaved changes” even though I correctly saved the page before leaving the page. I’m not sure what is causing this, but I’ll open another thread if this issue persists.

1 Like

Maybe worth submitting a ticket also on GH. Just not sure to main Grav repo or Admin :thinking: