Custom Collection for Footer?

I’m struggling with trying to figure out how to create a custom navigation list for my footer. I want to have a folder with pages, and have my footer navigation be populated with links to those pages.

This is what I feel like should work:


config.themes.steadystation.yaml

footnav:
    items:
        '@page.children': '/footnav'
    order:
        by: default
        dir: desc

base.html.twig

{% for p in config.themes.steadystation.footnav %}
{{ p.title }}

Pages Folder Structure

01.Home
02.Promo
03.Etc
footnav
  01.brands
  02.title
  03.info
  04.etc
images

The above doesn’t work.

I’ve tried lots of other things and cannot seem to get it to work. Is this even the right approach? Should I be defining a collection in the theme yaml? Do I even need a collection? My main nav is just using pages.children.visible in the TWIG. I don’t know how to edit that to only look in one folder. I’ve tried pages.footnav.children.visible, but that doesn’t seem to work.

I figured out how to do it with Taxonomies. I have not yet used taxonomies for anything yet, and this was an easy solution.

I edited config.site.yaml to have

taxonomies: [place]

Added the appropriate Taxonomy to each page:

 taxonomy:
     place: footer

Then used this in my TWIG:

{% for page in taxonomy.findTaxonomy({'place':'footer'}) %}

You can mark your own answer as a solution :wink:

I also use category taxonomy for that exact purpose. And I’m not sure themes can have page collections :thinking: I always thought they can be created only in page header

1 Like

@Karmalakas, See Programmatic collections:

You can take full control of collections directly from PHP in Grav plugins, themes, or even from Twig. This is a more hard-coded approach compared to defining them in your page frontmatter, but it also allows for more complex and flexible collections logic.

Probably that’s why I didn’t fixate that to my memory :slight_smile: I didn’t really use the usual way of getting collections on my site - everything is in my custom theme templates as page.children and similar