eZ Community » Forums » eZ Publish 5 Platform » Redirect to child node in ezpublish 5
expandshrink

Redirect to child node in ezpublish 5

Redirect to child node in ezpublish 5

Thursday 28 March 2013 8:58:03 am - 3 replies

Hi all,

how can I redirect to a child node like I did with the redirect template operator in ezpublish 5?

Thanks for a hint on that!

Thursday 28 March 2013 3:06:40 pm

Hi Andreas

This kind of things is not possible in templates any more in eZ Publish 5 / Symfony as it violates MVC...

There is currently no native way in eZ Publish to do such things, however you can hook into a kernel.request Symfony event in order to do a redirect. For this you need to implement an event listener.

The secret is to :

  1. Check if the request type is HttpKernelInterface::MASTER_REQUEST
  2. Do a setResponse() with a RedirectResponse
  3. Stop event propagation

Check this an example in eZ Publish kernel.

Note that you have access to locationId and viewType in the request attributes, so it's easy then to use the repository to do all your stuff.

Cheers !

Friday 29 March 2013 5:00:11 pm

Thanks Jérôme for your help!

Friday 29 March 2013 7:55:51 pm

A good candidate for the conversion cookbooks / documentation

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from