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

Trying to list all child page links with twig and not having any success

first-time

Started by Djay Ecks 8 years ago · 2 replies · 649 views
8 years ago

Hey all, I have a site and the taxonomy is something like this:

  • Home (default)
  • Stuff (category)
    -Stuff 1 (page)
    -Stuff 2 (page)
    -Stuff 3 (page)
  • Other stuff (category)
    ...

The goal is to make it so that category pages display content typed into the editor, followed by a listing of sub pages.

My initial code looks something like this.

TWIG
         {% block body %}
    <ul>
        {% for p in self.children %}
            <li><a href="{{p.url}}">{{ p.title }}</a></li>
        {% endfor %}
    </ul>
        {% block content %}
        {% endblock %}
    {% endblock %}

That doesn't seem to be doing what I want it to. I also tried page.children, category.children, @self.children, etc. etc. I can't seem to get that to spit anything out onto the page at all.

Can someone shed some light on what's happening here?

Thanks,

8 years ago

Nevermind, I'm an idiot -- I was putting this logic in the wrong place. I had this in a twig that was a partial, when I moved it into the layout itself it worked out a lot better.

Thanks,

Suggested topics

Topic Participants Replies Views Activity
Support · by Paul Hodges, 4 weeks ago
19 486 6 days ago
Support · by Lauw, 7 days ago
2 104 7 days ago
Support · by Anna, 3 weeks ago
4 426 1 week ago
Support · by gtx, 4 weeks ago
4 377 3 weeks ago
Support · by Anna, 1 month ago
9 484 4 weeks ago