zend-frameworkzend-navigation

zend navigation single level menu using xml file


With zend framework how do i create a single level menu?

I followed a tutorial and the person created a two level dropdown menu. I want to just remove home. I've modified the navigation.xml file a couple times and it caused a fatal error.

What xml markup do i need to promote the children of home as the parent level menus? As in i don't need a home button at all.

Desired outcome:

  • who
  • why
  • what
  • speaker
  • resources

Current outcome:

  • home

    • who

    • what

    • when

    • why

Current navigation.xml file:

<?xml version="1.0" encoding="UTF-8" ?>
<configdata>
  <nav>
    <home>
      <label>Home</label>
      <controller>page</controller>
      <action>index</action>
      <module>default</module>
      <pages>
        <why>
          <label>why</label>
          <controller>page</controller>
          <action>why</action>
          <module>default</module>
        </why>
        <who>
          <label>who</label>
          <controller>page</controller>
          <action>who</action>
        </who>
        <resources>
          <label>resources</label>
          <controller>page</controller>
          <action>resources</action>
        </resources>
        <signin>
          <label>sign in</label>
          <controller>account</controller>
          <action>login</action>
          <module>default</module>
        </signin>
      </pages>
    </home>
  </nav>

...

application/Bootstrap.php:

<?php function _initViewHelpers() {
   $this->bootstrap('layout);
   // ... Skipping to relevant part
    $navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
    $navContainer = new Zend_Navigation($navContainerConfig);
    $view->navigation($navContainer);
} ?>

layouts/default.phtml

<div class="navigation"><?php print $this->navigation(); ?></div>

Solution

  • <?xml version="1.0" encoding="UTF-8" ?>
    <configdata>
      <nav>
         <why>
          <label>why</label>
          <controller>page</controller>
          <action>why</action>
          <module>default</module>
        </why>
        <who>
          <label>who</label>
          <controller>page</controller>
          <action>who</action>
        </who>
        <resources>
          <label>resources</label>
          <controller>page</controller>
          <action>resources</action>
        </resources>
        <signin>
          <label>sign in</label>
          <controller>account</controller>
          <action>login</action>
          <module>default</module>
        </signin>
     </nav>