Jump to content

BDH

Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

BDH's Achievements

Newbie

Newbie (2/6)

3

Reputation

  1. Not at all, appreciate your help. I think I've found what I'm looking for: <?php function treeMenu(Page $page = null, Page $rootPage = null) { if(is_null($page)) $page = wire('page'); if(is_null($rootPage)) $rootPage = wire('pages')->get('/'); $out = "\n<ul>"; $parents = $page->parents; foreach($rootPage->children as $child) { $class = "level-" . count($child->parents); $s = ''; if($child->numChildren && $parents->has($child)) { $class .= " on_parent"; $s = str_replace("\n", "\n\t\t", treeMenu($page, $child)); } else if($child === $page) { $class .= " on_page"; if($page->numChildren) $s = str_replace("\n", "\n\t\t", treeMenu($page, $page)); } $class = " class='$class'"; $out .= "\n\t<li>\n\t\t<a$class href='{$child->url}'>{$child->title}</a>$s\n\t</li>"; } $out .= "\n</ul>"; return $out; } echo treeMenu($page, $page->rootParent);
  2. That is almost doing what I'm looking for, but it should only display the child page when the parent is active. Is that possible?
  3. I was looking for a navigation for something similar, to only display the child pages when their parent is active. <ul> <li>Team</li> <li>Offices</li> <ul> <li>London office</li> <li>New York office</li> <li>Berlin office<li> </ul> <li>History</li> <ul> <li>Photographs</li> <li>Archive</li> </ul> <li>Sales</li> </ul> I could get the navigation to output all child pages, but I only wanted the active parent's child pages to be shown. Hope that makes sense!
×
×
  • Create New...