0

I am using zend navigation in my site and I have the following navigation.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
<nav>
  <page1>
    <label>Site</label>
    <uri>/</uri>
    <pages>
        <page1_1>
            <label>Home</label>
            <uri>/</uri>
        </page1_1>
        <page1_2>
            <label>News</label>
            <uri>/news</uri>
        </page1_2>
        <page1_3>
            <label>Contact</label>
            <uri>/contact</uri>
        </page1_3>
    </pages>
  </page1>
 </nav>
</config>

Then I render the menu like below

<?=$this->navigation()->menu();?>

Output

- Site  
 - Home   
 - News  
 - Contact   

Wanted Output

- Site  
 - Home    
 - Contact   

How can I remove News item from the menu without affect other menu rendering?

Dayron Gallardo
  • 1,502
  • 2
  • 21
  • 37
dextervip
  • 4,999
  • 16
  • 65
  • 93

2 Answers2

3

Vou can hide menu entries with visible flag, that you add to the entry you would like to hide, in your case <page1_2>...</page1_2>:

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <nav>
    <page1>
      <label>Site</label>
      <uri>/</uri>
      <pages>
        ...
        <page1_2>
          <label>News</label>
          <uri>/news</uri>
          <visible>0</visible>
        </page1_2>
        ... 
      </pages>
    </page1>
  </nav>
</config>

Only use 0 or 1 within the xml file because false or true aren't recognized. All possible options you will find at Zend Framework: Documentation: Pages - Zend Framework Manual.

If you want the invisible entry in the breadcrumbs menu you can temporally disable the visible flag by adding setRenderInvisible( true )

<?= $this->navigation()->breadcrumbs()->setRenderInvisible( true ); ?>

All options of this helper you find here.

ByteNudger
  • 1,545
  • 5
  • 29
  • 37
0

Try using this:

<visible>0</visible>
sanders
  • 10,794
  • 27
  • 85
  • 127