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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Content & Markdown

Display pages with the same category

Started by Daimko 8 years ago · 4 replies · 1271 views
8 years ago

Hello,

I want to display the other pages with the same category as the current page. I added this code in blog_item.html.twig which displays all the pages right now :

TWIG
<ul class="liste-articles">
{% for p in page.parent.children if p != page %}
    <li>
        <a href="{{ p.url }}">{{ p.title }}</a>
    </li>
{% endfor %}
</ul>

Thank you in advance for your help !

8 years ago

Thank you,
I have read this page without finding a solution to my problem...
If anyone has an idea, I'm a taker !

8 years ago

@Daimko:
<ul class="liste-articles">
{% for p in page.parent.children if p != page %}
<li>
<a href="{{ p.url }}">{{ p.title }}</a>
</li>
{% endfor %}
</ul>

Hello,

Thank you for your help but I don't think I have been clear enough, sorry I'm French and I have trouble expressing myself correctly in English.

Simply put: All my articles are subpages of the home page that display them. At the end of each subpage, I want to display the other articles that have the same category as the current subpage. Currently, all subpages are displayed at the end of each article.

I hope I have been clear and thank you in advance for your help.

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 99 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 186 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 148 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 62 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 257 1 year ago