php - ZF2 Navigation: Set UL id attribute -


i'm trying use navigation build menu. however, need set id tag

<ul class="sf-menu" id="nav">     <li class="active">         <a href="/">home</a>     </li>     <li>         <a href="/api">api</a>     </li>     <li>         <a href="/a">baker , spice</a>     </li> </ul>   ' 

but, can't seem this.

i tried build html using foreach

<?php  foreach ($this->container $page){  } ?> 

it not doing because $this->container showing null.

please advice!

thanks in advance,

justin

if in view can call

echo $this->navigation('navigation')->menu(); 

and outputs menu correctly, must wanting create custom menu using partial view script (hence why you're using $this->container otherwise not set). make sure you've got this:

echo $this->navigation('navigation')->menu()           ->setpartial('my-module/partials/menu')->render(); 

and corresponding partial script: file named menu.phtml in module/mymodule/view/my-module/partials directory (for case).

// module/mymodule/view/my-module/partials/menu.phtml <ul class="sf-menu" id="nav"> <?php foreach ($this->container $page): ?>     <li <?= $page->isactive()? 'class="active"' : '' ?>>         <?= $this->navigation()->menu()->htmlify($page) ?>     </li> <?php endforeach; ?> </ul> 

(this gives single-level menu, on right path.)


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -