Zend Navigation. Submenu with custom option -


in layout script, need generate / render menu.

if menu item have submenu change menu item render <li class="submenu">

the reason have image on <li> element if subpages exits!

<ul>      <li>          <a href="/da/front/news">nyt</a>      </li>      <li class="submenu">          <a href="/da/front/events">aktiviteter</a>          <ul">              <li>                  <a href="/da/front/document/get/document/barserves-2010-2/doctype/html">barvagt</a>              </li>              <li>                  <a href="/da/front/events/history">afsluttede aktiviteter</a>              </li>          </ul>      </li>  <ul> 

this part of layout script

<?php $config = new zend_config_xml ( application_path . '/configs/navigation/front.xml' ); $container = new zend_navigation ( $config ); $this->navigation($container); echo $this->navigation()->menu()->render();  

found solution

my layout file

<?php global $config; $menuconfig = new zend_config_xml ( $config->navigation->file ); $container = new zend_navigation ( $menuconfig ); $this->navigation($container); $partial = array('menu.phtml','front'); $this->navigation()->menu()->setpartial($partial); echo $this->navigation()->menu()->render();  ?> 

and partial file

<?php  $html = array ();  $iterator = new recursiveiteratoriterator ( $this->container, recursiveiteratoriterator::self_first ); $prevdepth = - 1; foreach ( $iterator $page ) {     $depth = $iterator->getdepth ();     $isactive = $page->isactive ( true );     if ($depth > $prevdepth) {         $html [] = '<ul>' . "\n";     } else if ($prevdepth > $depth) {         for($i = $prevdepth; $i > $depth; $i --) {             $html [] = '</li>' . "\n";             $html [] = '</ul>' . "\n";         }         $html [] = '    </li>' . "\n";     } else {         $html [] = '    </li>' . "\n";     }     if ($page->haspages ()) {         $liclass = $isactive ? ' class="active submenu"' : ' class="submenu"';     } else {         $liclass = $isactive ? ' class="active"' : '';     }     $html [] = '<li' . $liclass . '>' . "\n";     $html [] = '<a href="' . $page->gethref () . '">' . $page->getlabel () . '</a>' . "\n";     $prevdepth = $depth; } echo join ( php_eol, $html ); 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -