Page 1 of 1
Howto create a link to a page and give a module of the page some parameters ?
Posted: Thu Mar 10, 2005 3:41 pm
by ghostrifle
Hey there,
I have something like a "preview" on the frontpage of my site. Now I want to click this preview to get to a specific page of the site and wanna give the module of this page some parameters. For now I'm doing
Well, ok so far, but I wanna give the module "MovieReview" some dynamic paramaters so that it shows directly a movie and not the whole listing. The link should look something like this:
Code: Select all
<a href="?page=Filme&movieid=666">bla</A>
So how do I do this ?? You know what I mean ??
Bye, ghostrifle
Re: Howto create a link to a page and give a module of the page some parameters ?
Posted: Thu Mar 10, 2005 4:31 pm
by Krol
Hi!
I found out, that, if you would do this on your frontpage:
Code: Select all
<a href="?page=Filme&m1movieid=666">bla</a>
and this in your module:
you probably are going to get this:
I don't know what exactly the "m1" means, but its in the $id of the module i'm writing right now.
Re: Howto create a link to a page and give a module of the page some parameters
Posted: Thu Mar 10, 2005 4:58 pm
by 100rk
ghostrifle wrote:
bla
Array $params[] is used for access to params of module declaration - for example if You will declare module like {cms_module module="YourModuleName" param1="whatever"}, You can access to parameter 'param1' through $params['param1'] - I am talking about body of function DoAction() of course...
So, if You will use anchor like bla, You can access to parameter 'movieid' by PHP superglobal variable $_GET['movieid'] or $_REQUEST['movieid'].
Note: use
Code: Select all
echo '<a href="?page=Filme&movieid=666">bla</a>';
instead of
Code: Select all
echo '<a href="?page=Filme&movieid=666">bla</a>';
Re: Howto create a link to a page and give a module of the page some parameters
Posted: Thu Mar 10, 2005 9:15 pm
by ghostrifle
OK thanks. I thought I could use $params for getting the $_GET variables too. I tried to avoid the $_GET... well without luck

Now it's working with $_GET.
Re: Howto create a link to a page and give a module of the page some parameters
Posted: Thu Mar 10, 2005 9:43 pm
by 100rk
ghostrifle wrote:
I thought I could use $params for getting the $_GET variables too.
I am SO SORRY, I was study documentation comments right now and You are partially right - array $params contains merged params from module declaration and all items of array $_REQUEST,
BUT (!!) with prefix ($id) of this module only. This is reason what array $params don't contains those values from Your HTML anchor, because You omit this 'id-prefix' and there is no way how to reliably determine which $id will module obtain from CMSMS at other page where it will be calling from. So, this is true reason why You have to use $_GET or $_REQUEST for Your purpose.

Of course, if You create module which will be called from already loaded page or from admin, I recommend to You using of its id prefix in requests - most simple way to do this is by using functions CreateXXXX() from class CMSModule (by example: I mean 'echo $this->CreateLink(....);' of course).
OR - there is best and clean way to do this - just turn this module into new content type like module News doing - page with content type 'News' is called by module 'News' from any page - and it can deliver GET parameters over different pages by 'CMSMS friendly' way.