Skip to content
Grav 2.1 is out: every page speaks Markdown. 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 · 679 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 complanar, 6 days ago
6 145 19 hours ago
Support · by Rick Beebe, 6 days ago
2 102 3 days ago
Support · by blu3prince, 3 days ago
0 54 3 days ago
Support · by alex, 4 days ago
2 95 3 days ago
Support · by Marcel, 2 weeks ago
1 145 4 days ago