Am 04.10.2011, 14:50 Uhr, schrieb Sergio Rinaudo <[email protected]>:


Dear ZF list,
I have this little problem with Zend Navigation and XML, my breadcrumbs look like this:

home => users => customers-list => customer-branches => customer-branch-edit

To access "customer-branches" page I need to have an user_id param.
To access "customer-branch-edit" page I need to have an user_id param and also a branch_id param.

If I am in the "customer-branch-edit" page I haven't found a way to make the breadcrumb link to "customer-branches" ( but also to "customer-branch-edit" )
render in the correct manner ( with the 'user_id' passed via GET ).

I added the param "user_id" to the XML navigation

                        <params>
                            <user_id></user_id>
                        </params>

and even if I have the "reset" set to false ( <reset>false</reset> ), apparently there is no way to render the value from the request.

For sure I am mistaking something.

How to solve this?

For example: Create an controller plugin.

class Application_Plugin_Navigation extends Zend_Controller_Plugin_Abstract
{
    /**
     *
     * @param Zend_Controller_Request_Abstract $request
     */
    public function postDispatch(Zend_Controller_Request_Abstract $request)
    {
        // Check controller and action
        if ('customer' == $request->getControllerName()
            && 'branches' == $request->getActionName())
        {
            // Get navigation container
            $container = Zend_Registry::get('Zend_Navigation');

            // Get page
            $page = $container->findOneBy('route', $routeName);

            if ($page instanceof Zend_Navigation_Page_Mvc) {
                // Set parameter (ID)
$page->setParams(array('user_id' => $request->getParam('id')));
            }
        }
    }
}


I prefer naming conventions for all routes: "controllerAction" and "moduleControllerAction".
In your case: "customerBranches" and "customersList"

In the plugin you can check:

// Create route name
$route = strtolower($request->getControllerName())
       . ucfirst(strtolower($request->getActionName()));

// Check current route
switch ($route) {
    case 'customerBranches':
    case 'customersList':
        // ...
        break;

    default:
        break;
}

http://framework.zend.com/manual/de/zend.controller.plugins.html

--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to