Search code examples
zend-frameworkzend-navigation

Zend Framework - how to apply icon in xml file and retriev it


When it load the xml file, the icon cause failure inside the label tags. How to fix it?

// horizontal top menu 
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <nav>

    <page1>
      <label><img src='icon.icon' /> Page 1</label>
      <controller>index</controller>
    </page1>


    <home>
      <label>Home</label>
      <controller>index</controller>
    </home>
  </nav>
</root>

// controller test
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
$container = new Zend_Navigation($config);
$this->view->navigation($container);

Solution

  • I suppose you could do it with CSS instead

    // horizontal top menu 
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
      <nav>
    
        <page1>
          <label>Page 1</label>
          <controller>index</controller>
          <class>menu-page1-icon</class>
        </page1>
    
      </nav>
    </root>
    

    CSS

    .menu-page1-icon:before {
        content: url(path/to/icon.icon);
    }