views:

30

answers:

2

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);
+1  A: 

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);
}
Jarsäter
Yes, it works with CSS method. Thanks#tested example:<style> .menu-page1-icon:before { content: url(icon/icon.icon);}</style><?php echo $this->navigation(); ?>
Stackfan
+1  A: 

It should probably be in a cdata section:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <nav>

    <page1>
      <label><![CDATA[<img src='icon.icon' /> Page 1]]></label>
      <controller>index</controller>
    </page1>


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

http://msdn.microsoft.com/en-us/library/ms256076.aspx

Ashley
@Ashley: Didn't worked, i have output in page as: <img src='icon.icon' /> Page 1 instead of "actual image Page1:"
Stackfan