Navigation helper renders only the route name, but not controller and action

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Navigation helper renders only the route name, but not controller and action

Andreas Möller
Hello List,


I'm struggling with the navigation view helper and/or routing.

To simplify this, I'm asking my question with the ZendSkeletonApplication as a basis. I have removed the home route, added a configuration key for the default navigation factory, added the default navigation factory as a navigation service.

Then I render the menu with the navigation view helper.

See here:

* https://gist.github.com/3851814

However, the urls that are rendered contain only "/application".

What am I missing here?


Best regards,

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


Reply | Threaded
Open this post in threaded view
|

AW: [fw-mvc] Navigation helper renders only the route name, but not controller and action

Marc Tempelmeier
Hi!

You have to use navigation/child_routes as the route in navigation if you wish to have the child routes added.



-----Ursprüngliche Nachricht-----
Von: Andreas Möller [mailto:[hidden email]]
Gesendet: Montag, 8. Oktober 2012 12:18
An: [hidden email]
Betreff: [fw-mvc] Navigation helper renders only the route name, but not controller and action

Hello List,


I'm struggling with the navigation view helper and/or routing.

To simplify this, I'm asking my question with the ZendSkeletonApplication as a basis. I have removed the home route, added a configuration key for the default navigation factory, added the default navigation factory as a navigation service.

Then I render the menu with the navigation view helper.

See here:

* https://gist.github.com/3851814

However, the urls that are rendered contain only "/application".

What am I missing here?


Best regards,

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



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


Reply | Threaded
Open this post in threaded view
|

AW: [fw-mvc] Navigation helper renders only the route name, but not controller and action

Marc Tempelmeier
In reply to this post by Andreas Möller
application/child-routes sorry :)

-----Ursprüngliche Nachricht-----
Von: Marc Tempelmeier [mailto:[hidden email]]
Gesendet: Montag, 8. Oktober 2012 12:22
An: [hidden email]
Betreff: AW: [fw-mvc] Navigation helper renders only the route name, but not controller and action

Hi!

You have to use navigation/child_routes as the route in navigation if you wish to have the child routes added.



-----Ursprüngliche Nachricht-----
Von: Andreas Möller [mailto:[hidden email]]
Gesendet: Montag, 8. Oktober 2012 12:18
An: [hidden email]
Betreff: [fw-mvc] Navigation helper renders only the route name, but not controller and action

Hello List,


I'm struggling with the navigation view helper and/or routing.

To simplify this, I'm asking my question with the ZendSkeletonApplication as a basis. I have removed the home route, added a configuration key for the default navigation factory, added the default navigation factory as a navigation service.

Then I render the menu with the navigation view helper.

See here:

* https://gist.github.com/3851814

However, the urls that are rendered contain only "/application".

What am I missing here?


Best regards,

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



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



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


Reply | Threaded
Open this post in threaded view
|

Re: Navigation helper renders only the route name, but not controller and action

Andreas Möller
Hello Marc,


Thanks a lot for your quick reply.

> application/child-routes sorry :)

That is, in the configuration for the navigation?

Like this:

    'navigation' => array(
        'default' => array(
            'home' => array(
                'label' => 'Home',
                'route' => 'application',
                'action' => 'index',
            ),
            'test' => array(
                'label' => 'Test',
                'route' => 'application/child-routes',
                'action' => 'extra',
            ),
        ),
    ),

. . . ?

Sorry, I don't get it - yet.


Best regards,

Andreas

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


Reply | Threaded
Open this post in threaded view
|

AW: [fw-mvc] Navigation helper renders only the route name, but not controller and action

Marc Tempelmeier
In reply to this post by Andreas Möller
The problem there is that you use a wildcard route which does not define
a specific route. I am using specific routes for my navigation which
works best I think.

Mixing the route with action I never got to work :(

-----Ursprüngliche Nachricht-----
Von: Andreas Möller [mailto:[hidden email]]
Gesendet: Montag, 8. Oktober 2012 12:29
An: [hidden email]
Betreff: Re: [fw-mvc] Navigation helper renders only the route name, but not controller and action

Hello Marc,


Thanks a lot for your quick reply.

> application/child-routes sorry :)

That is, in the configuration for the navigation?

Like this:

    'navigation' => array(
        'default' => array(
            'home' => array(
                'label' => 'Home',
                'route' => 'application',
                'action' => 'index',
            ),
            'test' => array(
                'label' => 'Test',
                'route' => 'application/child-routes',
                'action' => 'extra',
            ),
        ),
    ),

. . . ?

Sorry, I don't get it - yet.


Best regards,

Andreas

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



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


Reply | Threaded
Open this post in threaded view
|

Re: Navigation helper renders only the route name, but not controller and action

Andreas Möller
> The problem there is that you use a wildcard route which does not define
> a specific route. I am using specific routes for my navigation which
> works best I think.

But shouldn't there be a way to

* specifiy a route
* specifiy a navigation
* and render it

without having to define a route for every item in the navigation?

That's what I'm looking for.


Best regards,

Andreas

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


Reply | Threaded
Open this post in threaded view
|

Re: Navigation helper renders only the route name, but not controller and action

Andreas Möller
In reply to this post by Marc Tempelmeier
>> application/child-routes sorry :)

Got it to work. I understand now that I need to specify the complete name of the route.

That is, if I have a tree route defined, I need to specify path from the root to the specific node.


Thanks!


Best regards,

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


Reply | Threaded
Open this post in threaded view
|

AW: [fw-mvc] Navigation helper renders only the route name, but not controller and action

Marc Tempelmeier
In reply to this post by Andreas Möller
Hi,

can you explain that with a bit of code? I am interested if I can make it shorter instead what I have.

Thx :)

-----Ursprüngliche Nachricht-----
Von: Andreas Möller [mailto:[hidden email]]
Gesendet: Montag, 8. Oktober 2012 14:21
An: [hidden email]
Betreff: Re: [fw-mvc] Navigation helper renders only the route name, but not controller and action

>> application/child-routes sorry :)

Got it to work. I understand now that I need to specify the complete name of the route.

That is, if I have a tree route defined, I need to specify path from the root to the specific node.


Thanks!


Best regards,

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



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


Reply | Threaded
Open this post in threaded view
|

Re: Navigation helper renders only the route name, but not controller and action

Andreas Möller
> can you explain that with a bit of code? I am interested if I can make it shorter instead what I have.

In the configuration:

return array(
    'router' => array(
        'routes' => array(
            'application' => array(
                'type'    => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    'route'    => '/application',
                    'defaults' => array(
                        '__NAMESPACE__' => 'Application\Controller',
                        'controller'    => 'index',
                        'action'        => 'index',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    'default' => array(
                        'type'    => 'Zend\Mvc\Router\Http\Segment',
                        'options' => array(
                            'route'    => '/[:controller[/:action]]',
                            'constraints' => array(
                                'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                            ),
                            'defaults' => array(
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),
    'service_manager' => array(
        'factories' => array(
            'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
        ),
    ),
    'navigation' => array(
        'default' => array(
            'home' => array(
                'label' => 'Home',
                'route' => 'application',
                'action' => 'index',
            ),
            'foo' => array(
                'label' => 'Foo',
                'route' => 'application/default',
                'controller' => 'index',
                'action' => 'foo',
            ),
            'bar' => array(
                'label' => 'Bar',
                'route' => 'application/default',
                'controller' => 'index',
                'action' => 'bar',
            ),
        ),
    ),
);

If I understand it correctly, the defined routes have names, that is, for example: "application". The route "application" has a child "default". Now, in the configuration for the navigation, I have to specify "application/default", that is, the path from the root of the route tree ("application") to the route ("default"), which is "application/default". If the "default" route had a child named "baz" for other segments, I would have to specify that route in the navigation configuration as "application/default/baz".

Is that it?


Best regards,

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