[SOLVED] Obtain a module object reference cmsms 1.10.3
Posted: Mon Feb 20, 2012 11:56 am
Hi All,
I'm upgrading a module I was developing with cmsms 1.9.4.3 but I have a problem with an ajax file that writes in the db.
I make the ajax call from a module's template (.tpl).
My old, working, code in the ajax.php file:
If I call directly the ajax page, in cmsms 1.9.4.3, I can read the string "Module OK".
I've changed the code to obtain my module object reference, using the cms_utils::get_module() method:
If I call directly the ajax page, in cmsms 1.10.3, I cannot read the string "Module OK" and I got no reference to my module.
What am I doing wrong?
Thank you
I'm upgrading a module I was developing with cmsms 1.9.4.3 but I have a problem with an ajax file that writes in the db.
I make the ajax call from a module's template (.tpl).
My old, working, code in the ajax.php file:
Code: Select all
<?php
require '../../include.php';
$db=&$GLOBALS["gCms"]->db;
global $gCms;
if (!isset($gCms)) exit;
if (isset($gCms->modules['MyModule'])) {
$mymodule =& $gCms->modules['MyModule']['object'];
echo "Module OK";
}
I've changed the code to obtain my module object reference, using the cms_utils::get_module() method:
Code: Select all
<?php
require '../../include.php';
$db=&$GLOBALS["gCms"]->db;
global $gCms;
if (!isset($gCms)) exit;
if (isset(cms_utils::get_module('MyModule')) {
$mymodule = cms_utils::get_module('MyModule');
echo "Module OK";
}
What am I doing wrong?
Thank you