3

Hello I'm digging into this problem without finding a solution. It seems very simple but I turn around for a while.

I'm trying to highlight a parent and 1 child in a menu. Both have the same uri, but only the parent is getting the active class.

Here my xml:

<configData>
<apps>
<agenda>
    <label>Agenda</label>
    <uri>/apps/agenda</uri>

    <pages>
        <page1>
            <label>Page 1</label>
            <uri>/apps/agenda</uri>
        </page1>
        <page2>
            <label>Page 2</label>
            <uri>/apps/agenda/page2</uri>
        </page2>
    </pages>
</agenda>
</apps>
</configData>

here my .phtml:

<div>
    <?php echo $this->navigation(Zend_Registry::get('Zend_NavigationApp'))->menu()
            ->renderMenu(null, array(
            'minDepth' => null,
            'maxDepth' => 1,
            'ulClass' => 'navigation',
            'onlyActiveBranch' => false));
            ?>
</div>

and here the generated html:

<div>
<ul class="navigation">

<li class="active">
    <a href="/apps/agenda">Agenda</a>
    <ul>
        <li> /*Here the expected active class*/

            <a href="/apps/agenda">Page 1</a>
        </li>
        <li>
            <a href="/apps/agenda/page2">Page 2</a>
        </li>
    </ul>
</li>

</ul>
</div>

All that I want to do is to get the "li" parent and "li" child with an active class after I clicked the parent link.

1
  • If you have a solution please post it as an answer and then accept it when you can. That way the question will be marked as answered.
    – vascowhite
    Jan 5, 2012 at 17:48

1 Answer 1

2

Solution

Using MVC instead of URI style config xml file fixed all my problems.

Here my fixed xml:

<configData>
<apps>
<agenda>
    <label>Agenda</label>
    <module>module_1</module>
    <controller>control_1</controller>
    <action>action_1</action>
    <route>agenda_1</route>

    <pages>
        <page1>
            <label>Page 1</label>
            <module>module_1</module>
                    <controller>control_1</controller>
                    <action>action_1</action>
                    <route>agenda_1</route>
        </page1>
        <page2>
            <label>Page 2</label>
            <module>module_2</module>
                    <controller>control_2</controller>
                    <action>action_2</action>
                    <route>agenda_2</route>
        </page2>
    </pages>
</agenda>
</apps>
</configData>

Note that I'm using route definition in my ini file.

1
  • Is it compulsory to declare module and action?Any problem without declare?
    – dextervip
    Feb 16, 2012 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.