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

Collection Being Looped Through Twice

Started by Caylon Mc 5 years ago · 2 replies · 328 views
5 years ago

Happy New Years everyone.

So, I'm using Grav as a hobby and I am running into an issue - after updating from the last version my collection on a page looks like it is being run through twice in my For Each.

The folder structure is

TXT
Posts
|-- Mobile
|   |-- Mobile Post 1
|   |-- Mobile Post 2
|-- Pc
    |-- Pc Post 1
    |-- PC Post 2

On the posts file I have the header defined as :

YAML
title: Posts
process:
   twig: true
   markdown: false
twig_first: true
never_cache_twig: true
content:
   items: '@self.descendants'
   filter:
     non-visible: true
     type: item
   order:
      by: date
      dir: desct
   limit: 12
   pagination: 'true'

I've tried changing between .descendants and .children

and then the page code is:

TWIG
{% for p in page.collection %}
  <h2>{{ p.title|e }}</h2>
  {{ p.summary|raw }}
{% endfor %}

Thank you for any help!

last edited 01/01/21 by pamtbaau
5 years ago

Found the cause but not exactly - I was trying the bootstrap4 theme and the current version of it was causing this. The issue is not present in any other theme and the collections display properly.

5 years ago

@cfas,

I cannot reproduce the issue. I've:

  • installed theme Bootstrap4,
  • created a folder structure similar to yours and
  • added the frontmatter + code to /pages/02.posts/blog.md

The Posts page both shows a correct blog list of all descendants and show a correct list of children inside the pages content.

Question:

  • Is there a specific reason why you create a list of posts inside a page's content, instead of letting a template create the list?
last edited 01/01/21 by pamtbaau

Suggested topics

Topic Participants Replies Views Activity
Support · by Water Science, 3 weeks ago
11 164 2 hours ago
Support · by Duc , 18 hours ago
1 42 18 hours ago
Support · by Thomas, 1 week ago
3 116 1 day ago
Support · by Anna, 4 days ago
2 109 2 days ago
Support · by Justin Young, 2 days ago
1 86 2 days ago