I am working on integrating the Form Builder and Newsletters Made Simple modules. What I want is a single form which collects a bunch of data and then signs the user up for a newsletter (if requested, of course). I thought I could call one of the actions in the NMS from a User Defined Tag, but I don't know how to call another module's code. Is there an easy way to do this? The NMS has a do_create_new_user action, and if I add the correct params, I think it would just work.
Thanks,
Rorik
Calling code from other modules
Re: Calling code from other modules
Hi,
This isn't my development system, so I don't have access to my code but here goes :
This is rough, but it should gt you near.
This isn't my development system, so I don't have access to my code but here goes :
Code: Select all
$modulename = 'FormBuilder';
$cmsmodules = &$gCms->modules;
if (isset($cmsmodules[$modulename]))
{
if (isset($cmsmodules[$modulename]['object'])
&& $cmsmodules[$modulename]['installed'] == true
&& $cmsmodules[$modulename]['active'] == true ) {
$result = $cmsmodules[$modulename]['object']->YourFunctionCallHere();
}
This is rough, but it should gt you near.
--
Alan Ryan
Lead Developer
CodeCrunchers Internet Software Development - Ireland
http://www.codecrunchers.ie
Alan Ryan
Lead Developer
CodeCrunchers Internet Software Development - Ireland
http://www.codecrunchers.ie
Re: Calling code from other modules
Just for posterity, the code that ended up working in the User Defined Tag was this, very similar to what was suggested, but with a couple of wrinkles, like having to define the global $gCms var and such. Thanks for your help aln_cms!
//AddUsertoEmailList
//Adds user to Newsletter email list
$email = $params['Email'];
$params['email'] = $email;
$name = $params['Name'];
$params['username'] = $name;
$lists = array(1);
$params['lists'] = $lists;
$modulename = 'NMS';
global $gCms;
$cmsmodules = $gCms->modules;
if (isset($cmsmodules[$modulename]))
{
$returnid = 0;
$cmsmodules[$modulename]['object']->DoAction('do_create_new_user','',$params,$returnid);
}
//AddUsertoEmailList
//Adds user to Newsletter email list
$email = $params['Email'];
$params['email'] = $email;
$name = $params['Name'];
$params['username'] = $name;
$lists = array(1);
$params['lists'] = $lists;
$modulename = 'NMS';
global $gCms;
$cmsmodules = $gCms->modules;
if (isset($cmsmodules[$modulename]))
{
$returnid = 0;
$cmsmodules[$modulename]['object']->DoAction('do_create_new_user','',$params,$returnid);
}
Re: Calling code from other modules
my pleasure.
--
Alan Ryan
Lead Developer
CodeCrunchers Internet Software Development - Ireland
http://www.codecrunchers.ie
Alan Ryan
Lead Developer
CodeCrunchers Internet Software Development - Ireland
http://www.codecrunchers.ie
Re: Calling code from other modules
I've also made an UDT for this, check it out here.