Registering Smarty plugins for both frontend and admin

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
kristoftorfs
Forum Members
Forum Members
Posts: 11
Joined: Tue Jul 08, 2014 1:15 pm
Location: Belgium

Registering Smarty plugins for both frontend and admin

Post by kristoftorfs »

When I register a Smarty plugin in my module installation the plugin works perfectly on the frontend, but when I try to use them in the admin interface it keeps giving me an "unknown tag" error.

I tried to set the $usage argument of RegisterSmartyPlugin to 0, 1 and 2, but neither one of them seems to solve the problem.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Registering Smarty plugins for both frontend and admin

Post by calguy1000 »

Register your smarty plugins in your constructor.
but check to make sure that smarty has been initialized first.

i.e:

$smarty = cmsms()->GetSmarty();
if( $smarty ) {
$smarty->register_function('myfunction',$mycallable);
// note your plugin is now registered and available to all modules.
}
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.
kristoftorfs
Forum Members
Forum Members
Posts: 11
Joined: Tue Jul 08, 2014 1:15 pm
Location: Belgium

Re: Registering Smarty plugins for both frontend and admin

Post by kristoftorfs »

Okay, thanks.

But why is the $usage argument in CMSModule::RegisterSmartyPlugin then?

It doesn't seem like it's being used...
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Registering Smarty plugins for both frontend and admin

Post by calguy1000 »

RegisterSmartyPlugin is for registering a smarty plugin for your module name so that you can do something like this:

{MyModule}.

It's argument is whether or not to register that plugin dynamically (the default) which would be usually called in the InitializeFrontend() method or in the constructor.

When registering a plugin statically, (for when you want your module to lazy load). you call RegisterModulePlugin(true); in the install method.
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”