eZ Platform Discussions

UrlAliasGenerator and ViewParameters


#1

Hi All!

How could I use the UrlAliasGenerator class passing an array (key/value) of view parameters?

I need to generate a redirect from my controller adding view parameter

http://localhost:42080/content-1/content-2/(myparam)/myvalue
http://localhost:42080/content-1/content-2/(error)/item-not-found-error

I also need to generate this kind of url in Twig Templates using ez_urlalias but its appear it is not posible yet.

http://localhost:42080/content-1/content-2/(content-id)/40

Maybe this way to work is deprecated since Ez is fullstack symfony and I should now use normal get parameters in the url.

Any idea?


#2

Ok, from PHP I could generate my own service and use it on a RedirectResponse

This is how I use it in my controllers:

This is how I use it in my views:

Don’t forget to configure twig service availability:

Please let me know if you know something better.