$params doesn't work...
$params doesn't work...
Hi everyone, I'm tray to create link in my module with some params through CreateLink form CMSModule class, and I wont to 'catch' my params in target action debug_display() shows nothink beside 'action' param, but in $_GET array all is fine
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: $params doesn't work...
a) A specific code example would be useful.
b) a better description is necessary
is this a link to a frontend action, or an admin
I can assure you this code works, it's used in hundreds of modules every day.
b) a better description is necessary
is this a link to a frontend action, or an admin
I can assure you this code works, it's used in hundreds of modules every day.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: $params doesn't work...
I have function, which genereates list (ul, li) end foreach li element contains the link to action 'add_category' with some params, this link in my loop looks like this:
And, in my action.add_cateogry.php I have this code:
this code displays only param 'action' => 'add_category', but what about param1 in my link?
When I added $_GET['param1'] to mentioned code:
It's shows 'somethink'...
Code: Select all
$html .= "<li>" . $tree[$i]['name'] . " ".$this->CreateLink($id, 'add_category', $returnid, '<img src='.$this->GetModuleURLPath().'/images/add.gif />', array('param1'=>'somethink'), null, $onlyhref, $inline, $addttext)."\n";
Code: Select all
echo 'Add category';
debug_display($params['param1']);
When I added $_GET['param1'] to mentioned code:
Code: Select all
echo 'Add category';
//debug_display($params['param1']);
echo $_GET['param1'];
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: $params doesn't work...
I'm going to 'assume' that you're using the latest version of CMSMS, and that you are talking about a frontend action and not an action for the admin panel.
In your SetParameters method you probably have something like this:
The RestrictUnknownParameters() method tells the system that unless a parameter is 'registered' with the system that it should be stripped from the $params array. (Not having this line can generate a notice on frontend displays).
Therefore for each parameter you will be accepting in a frontend action you should call
i.e:
In your SetParameters method you probably have something like this:
Code: Select all
$this->RegisterModulePlugin();
$this->RestrictUnknownParameters();
Therefore for each parameter you will be accepting in a frontend action you should call
Code: Select all
$this->SetParameterType('param_name',CLEAN_xxxx);
Code: Select all
$this->SetParameterType('param1',CLEAN_STRING);
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: $params doesn't work...
Doesn't work...
I was added this code:
but it's still not working...:/
I was added this code:
Code: Select all
$this->CreateParameter('node_lft', '', $this->Lang('node_lft_help'));
$this->SetParameterType('node_lft', CLEAN_INT);
$this->CreateParameter('node_rgt', '', $this->Lang('node_rgt_help'));
$this->SetParameterType('node_rgt', CLEAN_INT);
Re: $params doesn't work...
In your example above you had a parameter called 'param1' in your code... Was this a hypothetical parameter? Or was it a real one, as I don't see it in your CreateParameter call.
Re: $params doesn't work...
Because now I'm using node_lft and node_rgt params... - param1 was mentioned for example...
Re: $params doesn't work...
OK...... In your example, you set some parameter to 'somethink'. However, in your SetParameterType call, you say 'CLEAN_INT' ... 'somethink' isn't an integer.
Re: $params doesn't work...
What exactly does your link look like and what is the value of $id?
Re: $params doesn't work...
in loop:
$id is nothink...:/, should I put to it some value? and early code:
and my action.add_category.php
Code: Select all
$html .= "<li>" . $tree[$i]['name'] . " ".$this->CreateLink($id, 'add_category', $returnid, '<img src='.$this->GetModuleURLPath().'/images/add.gif />', array('node_lft'=>$tree[$i]['lft'], 'node_rgt'=>$tree[$i]['rgt']), null, $onlyhref, $inline, $addttext)."\n";
Code: Select all
$this->CreateParameter('node_lft', null, $this->Lang('node_lft_help'));
$this->SetParameterType('node_lft', CLEAN_INT);
$this->CreateParameter('node_rgt', null, $this->Lang('node_rgt_help'));
$this->SetParameterType('node_rgt', CLEAN_INT);
Code: Select all
<?php
echo 'Add Category';
debug_display($params);
Re: $params doesn't work...
Did you overwrite $id somewhere? I usually get 'm1' if I only have one instance.
Please post the actual link created, not the PHP code used to post the link. Usually params passed into CreateLink will have the $id prepended to it, so it should look something like &m1node_lft=1
Please post the actual link created, not the PHP code used to post the link. Usually params passed into CreateLink will have the $id prepended to it, so it should look something like &m1node_lft=1
Re: $params doesn't work...
I don't override $id anywhere and it's looks like you said with prefix m1_node_lft=1etc....
Re: $params doesn't work...
Sorry, your posts are extremely confusing.
* You show detailed code using a parameter called 'param1', and later tell us that this is an example, and not the real one.
* It looks like you are passing strings in your example, but are using CLEAN_INT. It's hard to tell what is an example, and what is real.
* You say that $id is 'somethink', but later say it's 'm1'. There's no way that $_GET['node_lft'] will work when your link contains &m1node_lft=1
* You still haven't posted what the actual link looks like.
Please spend some time formulating your question, posting code, and verify that your information is correct. Half of the time I figure out the answer while posting, just because I spent some time making sure that my post is accurate and consistent with itself.
Please don't post 'examples'... post the actual code. Anything other than this is wasting our time.
* You show detailed code using a parameter called 'param1', and later tell us that this is an example, and not the real one.
* It looks like you are passing strings in your example, but are using CLEAN_INT. It's hard to tell what is an example, and what is real.
* You say that $id is 'somethink', but later say it's 'm1'. There's no way that $_GET['node_lft'] will work when your link contains &m1node_lft=1
* You still haven't posted what the actual link looks like.
Please spend some time formulating your question, posting code, and verify that your information is correct. Half of the time I figure out the answer while posting, just because I spent some time making sure that my post is accurate and consistent with itself.
Please don't post 'examples'... post the actual code. Anything other than this is wasting our time.