Page 1 of 1

Known issues in modules that need fixing

Posted: Mon May 19, 2014 8:36 pm
by calguy1000
A: global $gCms

The $gCms variable is provided in scope for module actions, and the install, uninstall, and upgrade methods. However, $gCms no longer exists as a global for any internal lib functions.

This global was long deprecated.

The best replacement is to change:

Code: Select all

global $gCms;
to

Code: Select all

$gCms = cmsms();
B: $gCms->variables

This internal variable was long deprecated, and a long time ago we prevented anybody from actually writing to that array. In 2.0 the array is gone.

Anybody using $gCms->variables stuff will need to find the appropriate replacement.

Replacements are:

Code: Select all

$gCms->variables['admintheme']
becomes

Code: Select all

cms_utils::get_theme_object();
Or better yet.... use the {admin_icon} plugin and {cms_action_url} plugins to create an icon directly in the template. i.e:

Code: Select all

<a href="{cms_action_url module='MyModule' action='something'}">{admin_icon icon='newobject.gif'} {$mod->Lang('new_item')}</a>
C: module tab functions

Somewhere in the 1.10.x or 1.11.x series (I don't wanna look it up), the $module->StartTabContent() and $module->EndTabContent() became smarter, and remembered some state variables. That means you can't do things like:

Code: Select all

$smarty->assign('endtab',$this->EndTab());
and then use {$endtab} in your action template multiple times.

The replacement is to use:

Code: Select all

{tab_header name='tab1' label='Tab 1'}
{tab_header name='tab2' label='Tab 2'}
{tab_start name='tab1'}
SOME CONTENT
{tab_start name='tab2'}
MORE CONTENT
{tab_end}

Re: Known issues that need fixing

Posted: Wed May 21, 2014 4:38 pm
by calguy1000
Also. Instead of hardcoding the search module
modules should be using:

Code: Select all

cms_utils::get_search_module();
when wanting to add/delete words from the index.

Re: Known issues that need fixing

Posted: Fri May 30, 2014 3:56 am
by calguy1000
Smarty usage in module constructors

Any module that uses smarty in their constructor must now check for smarty before usage.

i.e:
public function __construct()
{
parent::__construct()
$smarty = cmsms()->GetSmarty();
if( !$smarty ) return; // need to now check for smarty
$smarty->assign('foo','bar');
}
This is because modules may be loaded during the install/upgrade process (for upgrading and statistics gathering etc). And you cannot count on the fact that the CMSMS smarty will be available at that time.