Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6835799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:16:33+00:00 2026-05-26T23:16:33+00:00

I make a menu with Zend_Navigation. The trouble is that I detect a few

  • 0

I make a menu with Zend_Navigation.
The trouble is that I detect a few times “active menu” that is, the “li” of the current page.

Here is my navigation.xml

<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<nav>   
    <home>
        <label>Accueil</label>
        <controller>index</controller>
    </home> 

    <search>
        <label>Riads</label>
        <controller>search</controller>
        <action>index</action>
        <params>
            <q>allriads</q>
        </params>
    </search>

    <last>
        <label>Dernières Minutes</label>
        <uri>#</uri>
    </last>

    <promotion>
        <label>Promotions</label>
        <uri>#</uri>
    </promotion>

    <groupes>
        <label>Groupes</label>
        <uri>#</uri>
    </groupes>

    <contact>
        <label>Contact</label>
        <controller>apropros</controller>
        <action>contact</action>
    </contact>

</nav>

Here is the code in my bootstrap

/**
 * @return Zend_Navigation
 */
protected function _initNavigation()  
{
    $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
    $this->_view->navigation(new Zend_Navigation($config));
    $activeNav = $this->_view->navigation()->findByController('index');
    $activeNav->active = true;
    $activeNav->setClass("active");
}

Here is the HTML generated

<ul class="navigation">
<li class="active">
    <a class="active" href="/v2/">Accueil</a>
</li>
<li class="active">
    <a href="/v2/search/index/q/allriads">Riads</a>
</li>

<li>
    <a href="#">Dernières Minutes</a>
</li>
<li>
    <a href="#">Promotions</a>
</li>
<li>
    <a href="#">Groupes</a>

</li>
<li>
    <a href="/v2/apropros/contact">Contact</a>
</li>
</ul>

The good code must be :

<ul class="navigation">
<li>
    <a href="/v2/">Accueil</a>
</li>
<li>
   <a href="/v2/search/index/q/allriads">Riads</a>
</li>
[...]

What is the solution?

Sincerely,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:16:34+00:00Added an answer on May 26, 2026 at 11:16 pm

    My solution

    change your Bootrasp.php:

    public function _initNavigation()
    {
        $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
        $navigation = new Zend_Navigation($config);
        Zend_Registry::set('Zend_Navigation', $navigation);
    }
    

    In your layout.phtml

    <?=$this->navigation()->menu()->renderPartial(null, 'shared/menu.phtml')?>
    

    in the partial file: /application/views/shared/menu.phtmt write this:

    <ul class="navigation">
        <?
        foreach ($this->container as $page) :
        /** @var $page Zend_Navigation_Page_Mvc */
        ?>
            <li class="<?=$page->isActive(true) ? 'active' : ''?>">
                <a href="<?=$page->getHref()?>"><b><?=$page->label?></b></a>
            </li>
        <? endforeach; ?>
    </ul>
    

    By doing this, it inhibits the html generated by Zend_Navigator, but you decide to generate the html!
    I hope to check out was of help!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to make a navigation-menu where an active-class is applied to
Okay, so I want to make a menu that expands down at the current
I'm trying to make a context menu for a control that is linked to
I am trying to make a jquery menu that when I click on one
Is anyone using Zend Navigation in conjunction with URLs that require dynamic parameters? Zend_Navigation
I'm trying to make a menu that has different states depending of the width
I want to make a menu sort of similar to Yelps front page .
Is it possible to make a menu that will drop the child elements below
I'm trying to make a menu using tags, and you can see it here,
I have found this code to make a menu that collapses when the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.