Pages object from modular template?

I can’t figure out how to access the pages object from a module template as such:

{% for page in pages.children %}
  {{ page.title }}
{% endfor %}

By modular template I mean:
/user/themes/theme-name/templates/modular/module-template.html.twig

pages.children accepts a path, the page you route you want to inspect. see API

page.children on the other hand returns the children of the current page. API

On a modular child page, page.children usually is not set, do you want the parent page children? In this case you can get page.parent.children

Ok I think we’re on the right track. Actually I want the root for all the pages /users/pages/ but `pages.find(’/’).children’ doesn’t return anything.

pages.find('/') returns the home page. You want pages.all

I guess I’d need a code example to make pages.all work, cause it’s not.

My mistake. pages is a link to the root page (/users/pages/) so you can do

{% for page in pages.children %}
  {{ page.title }}
{% endfor %}

lol, we’ve come full circle… if you see the top of my post, I did exactly that. The problem is that it doesnt work from a template in templates/modular/template.html.twig

Ouch!
You’re right it seems the pages object is not directly accessible in modular childs. Use

{% for page in grav.pages.root.children %}
  {{ page.title }}
{% endfor %}

THANK YOU! Jeez that was messing with my head. You’re a god among insects! :slight_smile: