I am using $this->navigation()->breadcrumbs() and
$this->navigation()->menu() to output breadcrumbs and a menu
respectively.

When I use a custom route for ONE specific branch, the URIs of ALL
links produced by $this->navigation()->* are the same, with the
EXCEPTION of those in the branch specified by the custom route.


Non-custom route example
------------------------

http://www.example.com/en_US/debug/example/person/personId/jason/

Home > Debug > Example > Person > Jason

This works exactly as expected. ALL links produced by
$this->navigation()->* are correct.


Custom route example
--------------------

The goal is to shorten the URI to:

http://www.example.com/en_US/debug/example/person/jason/

(no 'personId')

I specify the following route:

<debug_example_person>
    <route>:locale/debug/example/person/:personId</route>
    <defaults>
        <locale />
        <module>debug</module>
        <controller>example</controller>
        <action>person</action>
        <personId />
    </defaults>
    <reqs>
        <locale>.*</locale>
        <module>.*</module>
        <controller>.*</controller>
        <action>.*</action>
        <personId>.*</personId>
    </reqs>
</debug_example_person>

The navigation container is specified as follows:

<debug>
    <type>Tx_Navigation_Page_Mvc</type>
    <module>debug</module>
    <controller>index</controller>
    <action>index</action>
    <label>Debug</label>
    <title>Debug</title>
    <pages>
        <example>
            <type>Tx_Navigation_Page_Mvc</type>
            <module>debug</module>
            <controller>example</controller>
            <action>index</action>
            <label>Example</label>
            <title>Example</title>
            <pages>
                <person>
                    <type>Tx_Navigation_Page_Mvc</type>
                    <module>debug</module>
                    <controller>example</controller>
                    <action>person</action>
                    <label>Person</label>
                    <title>Person</title>
                    <route>debug_example_person</route>
                    <id>debug_example_person</id>
                    <params>
                        <personId>overview</personId>
                    </params>
                </person>
            </pages>
        </example>
    </pages>
</debug>
<!-- many other branches -->

In Debug_ExampleController::personAction() I then update the
navigation container:

----

$request    = Zend_Controller_Front::getInstance()->getRequest();
$navigation = $this->getInvokeArg('bootstrap')->getResource('navigation');
$personId   = $this->_getParam('personId', null);

$newPage = new Tx_Navigation_Page_Mvc(array(

    'module'          => $request->getModuleName(),
    'controller'      => $request->getControllerName(),
    'action'          => $request->getActionName(),
    'params'          => array('personId' => $personId),
    'label'           => ucfirst($personId),
    'title'           => ucfirst($personId)
));

$page = $navigation->findOneBy('id', 'debug_example_person');
$page->addPage($newPage);

----

This correctly produces the desired breadcrumbs:

Home > Debug > Example > Person > Jason

when loading

http://www.example.com/en_US/debug/example/person/jason/

However -- and this is the problem -- the URI of ALL other links on
the ENTIRE site, produced by $this->navigation()->* is:

http://www.example.com/en_US/debug/example/person/

What am I doing wrong?

I am using ZF 1.8.3 (same in ZF 1.8.2).

Jonathan Maron

Reply via email to