I am trying to create a new route and I am not sure why it is not working.
I want to pass variables to an action:
/courses/list-courses?filter1=asd&filter2=fgh
It seems that CMSMS cleans the parameters so I can;t get this on my action. So I decided to create a new route like:
/courses/list-courses/filter1=asd&filter2=ghj
To do so I created a bit complicate expresion:
courses\/find-a-course\/((filter1+=(?P<filter1>\w+\-*)+(,\w+\-*)*)?)(&(?=\w))?((filter2+=(?P<filter2>\w+\-*)+(,\w+\-*)*)?)$
This way I could just assign the value of every filter to a $param.
When I try it I only get the first value but not the second. I have try the expresion in the following page http://pythex.org/ and it works ok.
Any ideas?
Thank you.
Regex problem
Re: Regex problem
That's not enough info on your part....skartknet wrote:I want to pass variables to an action:
/courses/list-courses?filter1=asd&filter2=fgh
It seems that CMSMS cleans the parameters so I can;t get this on my action
CMSMS clears the parameters passed to a module action if the module's RestrictUnknownParams() method is called on InitializeFrontend() method. In this case you'll need to call SetParameterType() method to register which parameters the module will accept. This doesn't have anything to do with module routes which are used to prettify the URL.
Look in the core modules, particularly in news source to see examples of use of those methods.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: Regex problem
OMG. I am so stupid. I thought that CMSMS removes all variables from URL as I wanted them to apear on $params, what I didn't realise is that I can get them from $_GET.
This is good enough for me but, is there anyway to have them on $params? I don't have RestrictUnknownParams() active.
Thanks.
This is good enough for me but, is there anyway to have them on $params? I don't have RestrictUnknownParams() active.
Thanks.
Re: Regex problem
You should have RestrictUnknownParams() active, as this improves security.skartknet wrote:I thought that CMSMS removes all variables from URL as I wanted them to apear on $params, what I didn't realise is that I can get them from $_GET.
This is good enough for me but, is there anyway to have them on $params? I don't have RestrictUnknownParams() active.
For a parameter to appear in the $params array of a particular module action it has to be directed at that particular module. Every module has an ID attributed by the CMSMS core and which is used for that particular purpose. The best way to create valid links for module actions with the appropriate parameters included is through the module API.
Ref: Additionally you can (as I said previously) look at the News module source, particularly at the default action file, for samples of it's use, and install and inspect the Skeleton module which is very well documented on its source files.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!