Looping through navigation items with navgroups

  • Hi,

    I'm building a sitemap for a multilingual site that contains a set of navgroups with slugs en-discover-nav, es-discover-nav and fr-discover-nav. I can get the output I need by calling each navgroup individually e.g.

    1. perch_pages_navigation(array(
    2. 'template' => 'sitemap.html',
    3. 'navgroup' => 'en-discover-nav',
    4. ));

    But I'd like to loop over the language options instead to do this more programmatically. I've tried the following, but I don't get the expected / hoped for output. Instead I get just the very top level of the site navigation, and nothing from the navgroups.

    1. $langs = array('en', 'es', 'fr');
    2. foreach ($langs as $lang) {
    3. perch_pages_navigation(array(
    4. 'template' => 'sitemap.html',
    5. 'nav-group' => $lang . '-discover-nav',
    6. ));}

    I'm using a similar loop with perch_blog_custom and perch_collection and I'm getting the results that I'm looking for.

    Is there a reason why this won't work with perch_pages_navigation? Is there something wrong with my approach?

    Many thanks in advance for any feedback or help.

  • drewm

    Approved the thread.
  • Hi,

    Just to add a little more info to this. I can loop over an array of language options to build a sitemap for multiple blogs using the following:

    And I'm using a similar foreach loop with perch_collection which is returning exactly what I'm looking for.

    But using a foreach loop with perch_pages_navigation and navgroup isn't getting the expected output.

    Any help would be much appreciated!