i've got a simple navigation menu like this:
$container = new Zend_Navigation();
$container->addPage(array(
'label' => 'Page 1',
'uri' => 'page-1',
'foo' => 'bar',
'pages' => array(
array(
'label' => 'Page 1.1',
'uri' => 'page-1.1',
'foo' => 'bar',
),
array(
'label' => 'Page 1.2',
'uri' => 'page-1.2',
'class' => 'my-class',
)
),
...
this will generate :
ul
li
li
how do i ass a class / id to the ul
or to the li
?
any ideas?
thanks
edit: i found a different solution:
i use this function
public static function htmlify($container, $menu_name = null)
{
$i = 0;
$menu = '<ul class="'.$menu_name.'">';
foreach($container as $page)
{
$menu .= '<li id="'.$page->htmlfyId.'"><a id="menu-'.$page->id.'" class="'.$page->class.'" href="'.$page->uri.'">'.$page->label.'</a>';
$menu .= '<ul id="'.$page->htmlfyClass.'">';
foreach($page as $pages)
{
$menu .= '<li id="li"><a class="'.$page->class.'" href="'.$pages->uri.'">'.$pages.'</a></li>';
}
$menu .= '</li>';
$menu .= '</ul>';
}
return $menu;
}
then in the method that holds the menu add:
$view = Zend_Layout::getMvcInstance()->getView();
$menu = self::htmlify($container, 'navigation');
$view->menu = $menu;
return $menu;
my class has static methods and u have to echo class::method
in the view, otherwise just use a regular $this->menu
or whatever.
then u can use it like this:
$container = new Zend_Navigation();
$container->addPage(array(
'label' => 'Page 1',
'uri' => 'page-1',
'foo' => 'bar',
'htmlfyId' => 'testing',
'htmlfyClass' => 'test',
'pages' => array(
array(
'label' => 'Page 1.1',
'uri' => 'page-1.1',
'foo' => 'bar',
),
array(
'label' => 'Page 1.2',
'uri' => 'page-1.2',
'class' => 'my-class',
)
),
...
To add a class on ul try this
$options['ulClass'] = 'foo';
<?php echo $this->menu($container)->renderMenu($container,$options); ?>
where $container is your Zend_Navigation object.