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

How to show a collection

Started by Muut Archive 10 years ago · 2 replies · 435 views
10 years ago

How can I show a collection inside a page?
This is my .md page

TXT

title: 'Quote Archive '
published: true
metadata:
keywords: 'home'
taxonomy:
category:

  • main
    tag:
  • 'home'
    menu: 'Home'
    slug: home
    process:
    markdown: false
    twig: true
    routable: true
    cache_enable: true
    visible: true
    content:
    items: '@root'
    TWIG
    {% for p in page.collection %}
    <h2> {{ p.title }} </h2>
    {{ p.summary }}
    {% endfor %} 
    

this is the result:
screencapture-quotesarchive-xyz-en-1470944070522
how can I not show the collection code before the collection?

10 years ago

I really can't tell with your paste of the .md page, you should paste it between triple backticks.

10 years ago

sorry for the bad paste. My problem is:
If I have a page writed this way:
(savedd home.en.md)

YAML

title: 'Home'
published: true
metadata:
    keywords: 'home'
taxonomy:
    category:        - main
    tag: - 'home'
menu: 'Home'
slug: home
process:
    twig: true
routable: true
cache_enable: true
visible: true
content:
    items: @root
    order:
        by: date
        dir: desc 
    limit: 10
    pagination: true

and this flat text after "This Are all our Pages:"

how and where do I have to add the twig text?

TWIG

{% for p in page.collection %}
<h3> {{ p.title }} </h3>
 {{ p.summary }}
{% endfor %}
---

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1362 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2959 9 years ago
Archive · by Muut Archive, 9 years ago
3 1124 9 years ago