Known issues in modules that need fixing

A forum for module developers to discuss how to convert their modules to be compatible with CMSMS 2.0. Please read the APIDOC at http://www.cmsmadesimple.org/APIDOC2_0/
Post Reply
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Known issues in modules that need fixing

Post 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}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Known issues that need fixing

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Known issues that need fixing

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Post Reply

Return to “Module Developers”