Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

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 · 715 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 webmasterodp, 1 week ago
4 160 6 days ago
Support · by nwhitfield, 1 week ago
2 137 1 week ago
Support · by stell, 3 weeks ago
5 370 2 weeks ago
Support · by gravinator, 1 month ago
5 562 2 weeks ago
Support · by Gravver, 3 weeks ago
6 348 3 weeks ago