|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
matija Smarty n00b
Joined: 20 Nov 2007 Posts: 3
|
Posted: Tue Nov 20, 2007 6:43 am Post subject: register_function without function |
|
|
hi!
i have (maybe stange) problem. my so-called "system" works with plugins. i can control plugin with turn it on/off via control panel. in plugins are predefined smarty functions, like:
Code: | $smarty->register_function ('call_me', 'my_function'); |
... of course, i call it in my templates with {call_me}.
and the question here is: what if i turn off this "plugin" ... then (php) function will not exists anymore, also "register_function" will disappear from "defined functions". and yes, in templates "{call_me}" will be still there.
how can i avoid "unrecognized tag" error? is there any variable that i could turn errors to off, or just this one, or is there any other solution?
in other words: i don't want smarty template error with call {foo_smth}, if foo_smth is not defined. got it?
greetings and thanks,
matija |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Nov 28, 2007 9:31 pm Post subject: |
|
|
There is no facility for this, though you may be able to trap the error in a custom error handler if you are ambitious that way. |
|
Back to top |
|
DaanK Smarty Rookie
Joined: 02 May 2006 Posts: 5 Location: /home/daank
|
Posted: Thu Nov 29, 2007 8:41 am Post subject: |
|
|
Might be overkill, but you could write a plugin which dynamically includes other plugins.
example
Code: |
<?php
# $Id: $
function MyDynamicPlugins ($params, &$smarty) {
global $objMysql, $objSmarty;
/*
Place code here to fetch dynamic plugin list.
*/
return isset($plugin)?$plugin:null;
}
$objSmarty->register_function("dynamicplugin","MyDynamicPlugins");
?>
|
And place something like this in your template
Code: |
{dynamicplugin fetch="ContactPlugin" vars="vars"}
|
|
|
Back to top |
|
rodneyrehm Administrator
Joined: 30 Mar 2007 Posts: 674 Location: Germany, border to Switzerland
|
Posted: Thu Nov 29, 2007 11:48 am Post subject: |
|
|
boots wrote: | There is no facility for this, though you may be able to trap the error in a custom error handler if you are ambitious that way. |
have i missed the spot where you could define a callback for handling smarty-errors, or are you talking about a global error handler? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Nov 29, 2007 5:46 pm Post subject: |
|
|
You're eyes are fine -- I meant the php global error handler |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|