Page 1 of 1

urlparam and pretty urls

Posted: Mon Mar 23, 2009 10:38 pm
by cnisvcs
This seems to be a basic stuff, but I cant't find the answer. I need to modify the content of a specific page if it is entered from another specific page. Seems that you accomplish that by adding urlparam to the {cms_selflink} on the originating page and check for the existence of that parameter on the destination page with {if $smarty.get.myparamhere}. Well, it doesn't work for me. My selflink tag looks like the one below:

{cms_selflink page="page-alias" text="Back" urlparam="&myparam=1"}

The url used by the browser is:

http://www.mywebsite.com/index.php/page-alias&myparam=1

and the browser shows error 404.

I should have mentioned that pretty urls are turned on for this site, but I never found the indication, that pretty urls don't like urlparam.

I disabled the pretty urls to move on with this, but, if posible, I would like to have them on and parse the parameters between pages using GET method. Is that possible? If so, how?

Re: urlparam and pretty urls

Posted: Tue Mar 24, 2009 4:41 pm
by CWebguy
Your first parameter needs to come after a question mark and not an ampersand (&).

Cheers!

Re: urlparam and pretty urls

Posted: Tue Mar 24, 2009 9:04 pm
by cnisvcs
Thanks for the response, WebGuy. The first parameter is "page-alias", which in pretty urls comes after index.php/. I don't think the question mark is used when pretty urls are turned on.

It just seems like with pretty urls you can parse only one parameter using GET method and it is the page alias. I would love if one of developers indicated whether I'm right or wrong.

BTW, in the process of experimenting with different syntax I tried

http://www.mywebsite.com/index.php/page-alias?myparam=1

but that gave me 404 as well.

Re: urlparam and pretty urls

Posted: Tue Mar 24, 2009 9:22 pm
by CWebguy
You have to change your rewrite code to fetch the variable if that's what you are trying to do.

Try changing

RewriteRule ^(.+)$ index.php?page=$1 [QSA]

to

RewriteRule ^(.+)&(.+)$ index.php?page=$1&param=$2 [QSA]

Re: urlparam and pretty urls

Posted: Tue Mar 24, 2009 9:28 pm
by CWebguy
what's happening is you are doing the url

pagename&parameter=2

but the server is doing

index.php?page=pagename&parameter=2

Which it can't find cause it doesn't exist.

Cheers,

Re: urlparam and pretty urls

Posted: Tue Mar 24, 2009 11:02 pm
by CWebguy
sorry I gave you bad code, isn't hard to explain.  I don't want to mess it up if someone else can explain this better, if not I'll be happy to help.

Take care.