Jump to content

Foundation 'top-bar' does not show children. WHY?


OrganizedFellow
 Share

Recommended Posts

Hiya gang!

:)

I'm using Foundation 5 for my CSS framework.

I took the following code from Zurb Foundation 4 Site Profile.

		<div class="contain-to-grid">
			<nav class="top-bar" data-topbar>
				<section class="top-bar-section">
					<ul class="left">
						<?php
							$homepage = $pages->get('/');
							/**
							 * Render items for placement in Foundation 'top-bar' recursive drop-down navigation
							 *
							 */
							function renderTopNav(PageArray $items, array $options = array(), $level = 0) {
								$defaults = array(
									'tree' => 2, // number of levels it should recurse into the tree
									'dividers' => true,
									'repeat' => true, // whether to repeat items with children as first item in their children nav
									);
								$options = array_merge($defaults, $options); 
								$divider = $options['dividers'] ? "<li class='divider'></li>" : "";
								$page = wire('page');
								$out = '';
								foreach($items as $item) {
									$numChildren = $item->numChildren(true);
									if($level+1 > $options['tree'] || $item->id == 1) $numChildren = 0;
									$class = '';
									if($numChildren) $class .= "has-dropdown ";
									if($page->id == $item->id) $class .= "current ";
									if(($item->id > 1 && $page->parents->has($item)) || $page->id == $item->id) $class .= "active ";
									if($class) $class = " class='" . trim($class) . "'";
									$out .= "$divider<li$class><a href='$item->url'>$item->title</a>";
									if($numChildren) {
										$out .= "<ul class='dropdown'>";
										if($options['repeat']) $out .= "$divider<li><a href='$item->url'>$item->title</a></li>";
										$out .= renderTopNav($item->children, $options, $level+1); 
										$out .= "</ul>";
									}
									$out .= "</li>";
								}
								return $out; 
							}
						?>
						<?php echo renderTopNav($homepage->children->prepend($homepage)); ?>
					</ul>
				</section>
			</nav>
		</div>

Here is what my tree looks like:

post-609-0-60047600-1413227340_thumb.png

It almost displays as expected, but the child pages of 'Testimonials' does not show in the drop menu. ONly the root shows

Why not?

I've even changed this to a larger number, but still ... no children.

                                    'tree' => 2, // number of levels it should recurse into the tree

Link to comment
Share on other sites

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...