Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

register_function without function

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
matija
Smarty n00b


Joined: 20 Nov 2007
Posts: 3

PostPosted: Tue Nov 20, 2007 6:43 am    Post subject: register_function without function Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Nov 28, 2007 9:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
DaanK
Smarty Rookie


Joined: 02 May 2006
Posts: 5
Location: /home/daank

PostPosted: Thu Nov 29, 2007 8:41 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 674
Location: Germany, border to Switzerland

PostPosted: Thu Nov 29, 2007 11:48 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu Nov 29, 2007 5:46 pm    Post subject: Reply with quote

You're eyes are fine -- I meant the php global error handler Wink
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP