Module Development - having trouble with $params

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Locked
jbad
Forum Members
Forum Members
Posts: 12
Joined: Fri Nov 14, 2008 12:08 am

Module Development - having trouble with $params

Post by jbad »

I'm developing a module and am having trouble retrieving parameters from the page URL. I'm using v1.11.11.

I'd like to have a parameter 'month' made available to the module, from the page parameter 'month':

http://example.com/index.php?page=test&month=1

I bought the CMS Made Simple Development Cookbook to help, and it seems that I need to prepend my parameter name with the $id variable present in my action. So if $id='m8b20b', the example would become:

http://example.com/index.php?page=test&m8b20bmonth=1

Whenever I output the $params variable in my action, all that is listed is 'module' and 'action'...

Code: Select all

debug_display($params, 'Parameters');
yields:

Code: Select all

Debug display of 'Parameters':(0.128146) - (usage: 12802112) - (peak: 12939184)

Number of elements: 2
Array
(
    [module] => CCBCalendar
    [action] => monthList
)


Inside of my module.php, here's what I have regarding parameters:

Code: Select all

function InitializeFrontend() {
	$this->RestrictUnknownParams();	
	$this->SetParameterType('month', CLEAN_INT);
}

function InitializeAdmin() {
	$this->CreateParameter('month', -1, 'Month');
}
I've removed the above code to see if the parameter comes through. I'll then see the messages in the admin log about not properly cleaning input params, but I haven't managed to get the parameter to come through yet. I'm betting this is something really simple I'm missing...

Thanks!
Jon
Last edited by Jo Morg on Thu Sep 04, 2014 7:58 pm, edited 1 time in total.
Reason: Please avoid auto-link of pseudo links by using "Do not automatically parse URLs" checkbox option. Thanks.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1922
Joined: Mon Jan 29, 2007 4:47 pm

Re: Module Development - having trouble with $params

Post by Jo Morg »

We need way more info about what you are trying to do and how you are trying to do it.
How are you passing the parameters? Are you using a template? Not?
jbad wrote:I bought the CMS Made Simple Development Cookbook to help, and it seems that I need to prepend my parameter name with the $id variable present in my action.
The book, although a bit outdated, still has most of what you need to build a link for a module action with parameters properly set.
For more updated docs about CMSMS API check this: http://apidoc.cmsmadesimple.org
(particularly the Class CMSModule and the CreateLink method), where you'll find what you need.
HTH
"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!
jbad
Forum Members
Forum Members
Posts: 12
Joined: Fri Nov 14, 2008 12:08 am

Re: Module Development - having trouble with $params

Post by jbad »

Sorry. I'm new enough with this that I'm not certain what all I need to provide. I'll look through the link you sent and see if anything looks to help.

Overall Goal
In years past, my client has utilized the (great) CGCalendar for their calendar needs. However, in the past year they've upgraded their customer relationship system and it has built-in calendaring functionality that's quite nice. My goal is to synchronize the public events from their new calendar system (which has a web service) into a table on their site (which runs CMSMS), and display the data similarly to how CGCalendar does now.

What I've done so far
To achieve this, I've built a module (named CCBCalendar) that will have several modes, the first of which is a monthly listing. To use the monthly listing, I planned to add the following smarty tag into a "calendar" page:

Code: Select all

{cms_module module='CCBCalendar' action='monthList' }
I have my actions separated out from the main module.php file, and have also implemented a template for the monthList. This is all working - I've got the database call working, and the display of the data in the template working.

The next step is to utilize page url parameters to determine which month's worth of events to view. It seemed like the right way to do this was to utilize the $params variable in my action.monthList.php file. This is where I'm stuck, as I'm not seeing any page parameters being made available in the $params variable. Here's the relevant content of my action.monthList.php file:

Code: Select all

// Security Checks
if (!isset($gCms)) exit;
$this->smarty->assign_by_ref('mod', $this);

echo '<h1>'.$id.'</h1>';
debug_display($params, 'Parameters');
If I'm missing something else that could help, I'll gladly provide it. Thanks :)
jbad
Forum Members
Forum Members
Posts: 12
Joined: Fri Nov 14, 2008 12:08 am

Re: Module Development - having trouble with $params

Post by jbad »

So - using CreateLink works fine. This takes the browser to :

http://example.com/index.php?mact=CCBCalendar,cntnt01,monthList,0&cntnt01month=10&cntnt01year=2014&cntnt01returnid=57

This could work for my use-case, but I'd love to understand how/if URL parameters can be accessed just when using the cms_module tag on a page.
Locked

Return to “Developers Discussion”