eZ Community » Forums » eZ Publish 5 Platform » How to change default route to add...
expandshrink

How to change default route to add custom parameter

How to change default route to add custom parameter

Wednesday 18 February 2015 10:18:56 am - 9 replies

What I want to achieve is friendly url

from: http://ezpublish5/somefolder?f=gallery (what I have now)

to: http://ezpublish5/somefolder/gallery

Wednesday 18 February 2015 1:06:34 pm

Hello Tomasz,

Welcome to the eZ Community!

My first question would why exactly do you need this, what is the use case?

Normally /somefolder/gallery is the location name/uri (gallery) of an item in the content tree or some other custom controller route. Which are you using in this situation?

You should be able to create this content tree item (say of class gallery) under the 'somefolder' location and link directly to it.

Otherwise if your using a custom controller perhaps this related documentation will help. https://doc.ez.no/display/EZP/1.+Getting+started#id-1.Gettingstarted-routing.yml

I hope this helps!

Cheers,
Heath

Wednesday 18 February 2015 3:47:33 pm

Hey, thanks for reply.

In my project folder is a place which contains articles. Some of articles are just common articles and some of them are galleries with photos. I want to give user possibility to filter that folder if he want to see only a galleries or just articles. Already did that with http://ezpublish5/somefolder?f=gallery, "f" is a filter used in controller action in my query. Now I wonder if there is any possibility to change that url for more user friendly for example http://ezpublish5/somefolder/gallery where gallery will be still that "f" parameter for my query.

Wednesday 18 February 2015 5:04:18 pm

Hello Tomasz,

I do not know (myself) how to do what your asking for without creating a custom controller (for 'somefolder' uri).

The link I shared above clearly shows how to do that. Though this other documentation might help as well. I'm not sure, it comes highly recommended by others but I'm not sure it supports the additional uri parameter your trying to use re: '/gallery'.

https://doc.ez.no/display/EZP/How+to+use+a+custom+controller+to+display+a+content+or+location#Howtouseacustomcontrollertodisplayacontentorlocation-Enrichingbuilt-inViewController

Alternatively I would use view parameters instead of get parameters as they are built-in and much better to work with. https://doc.ez.no/display/EZP/Twig+Helper

In short for what you are in the end trying to do. My solution for this has -always been- to use view parameters.

I hope this helps!

Cheers,
Heath

Wednesday 18 February 2015 6:50:42 pm

Hey,

I am using democontroller from demobundle (2014.11 version) as example for learn.

At the moment I have about 20 folders and according to: https://doc.ez.no/display/EZP/1.+Getting+started#id-1.Gettingstarted-routing.yml I should create 20 new routes?

Wednesday 18 February 2015 8:31:00 pm

Look and Listen ...

Heath was trying to be nice but your obviously not listening to the youtube video music!!

What your doing is dead wrong. Please for the love of anything good left in this dark matter universe STOP! Just stop, your hurting yourself and now your hurting others.

You should not be trying to mix concepts here. Your killing innocent children trying to do what your trying to do and it's disgusting.

Urls to content tree content do not support the notion of additional uri elements as additional parameters, at all, and god save us .. never should -ever-. Each uri segment represents a node uri alias in the content tree.

/somefolder is a node, /somefolder/gallery is a child node to /somefolder

And that's the way it should be. You need to stop, right now. I forbid you to proceed. You do not need custom controllers either.

You need to use view parameters. They were designed for the exact need you have right now. USE view parameters!

//kracker

THEMEEminem - Hate em ...

https://www.youtube.com/watch?v=yeoEMBEzLAs

Eminem - F*ck You ...

https://www.youtube.com/watch?v=eRaCZMhGzbk#t=13

Modified on Wednesday 18 February 2015 8:32:33 pm by // kracker

Wednesday 18 February 2015 10:40:47 pm

What I found about view parameters is that I can get something like that: http://ezpublish5/somefolder/(f)/gallery.

Is this what you are talking about //kracker?

Wednesday 18 February 2015 11:06:48 pm

Hello Tomasz,

Yes that is a valid URL example of a single view parameter.

I hope this helps!

Cheers,
Heath

Thursday 19 February 2015 11:59:40 am

Hey,

Thank you for help.

Thursday 19 February 2015 12:14:48 pm

Hello Tomasz,

Happy we could help! Feel free to ask more questions in here in the forums!

If your question is resolved ... could you help us out and login to share.ez.no and click the question resolved icon at the top of your original forum message title?

It's the box with the checkbox inside. It turns green when you have clicked it correctly.

Doing this indicates your question has been solved.

Thanks again for your continued support!

If your question is not resolved, please do let us know what more we can do to help!

Cheers,
Heath

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from