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.
Registering Smarty plugins for both frontend and admin
-
- Forum Members
- Posts: 11
- Joined: Tue Jul 08, 2014 1:15 pm
- Location: Belgium
-
- 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
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.
}
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.
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.
-
- Forum Members
- Posts: 11
- Joined: Tue Jul 08, 2014 1:15 pm
- Location: Belgium
Re: Registering Smarty plugins for both frontend and admin
Okay, thanks.
But why is the $usage argument in CMSModule::RegisterSmartyPlugin then?
It doesn't seem like it's being used...
But why is the $usage argument in CMSModule::RegisterSmartyPlugin then?
It doesn't seem like it's being used...
-
- 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
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.
{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.
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.