Re: [SMARTY] Re: Should I use Prefilter or Plugin for "advanced"
| From: | Jochem Maas | Date: | Thu, 29 Apr 2004 17:56:40 +0000 |
| Subject: | Re: [SMARTY] Re: Should I use Prefilter or Plugin for "advanced" | ||
| References: | 1 2 3 4 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11321@lists.php.net to get a copy of this message | ||
Hi Tommy,
just saw your message: here's something that will hopefully get you started:
the function that created the ness. HTML/javascript for the {popup} tag
is in the file <SMARTY_DIR>/plugins/function.popup.php
have a look at it and you'll probably see quite quickly to make a plugins. anyway you need to create a file in the same directory (lets call it 'function.tommypopup.php') then put something like the following
code in this file (I leave the meat of the function to you):
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty {tommypopup} function plugin
*
* Type: function<br> * Name: tommypopup<br>* Purpose: make a specialized text pop up in windows via overlib * @param array * @param Smarty * @return string */ function smarty_function_tommypopup($params, &$smarty) {
extract($params);
// do some sanity checks on the parameters -
// take a look at other plugins to see how they do this
// (incl. thowing errors)
$params['text'] = $params['helptext'];
$params['caption'] = $params['header'];
$params['delay'] = 300;
$link = "<ahref=\"/admin/helppopup.php?id={$helpid}\" target=\"ticmshelp" onclick=\"link_popup(this);return false\" ";
$link .= smarty_function_popup($params, $smarty);
$link .= "><img
class=\"helpicon\"
src=\"/admin/images/icon_help.gif\"
alt=\"\" /></a>";
return $link;} /* vim: set expandtab: */ ?> BTW: I don't know if it matters having underscores en capitals in the name of the function (i.e. {TI_Help_popup} - but I'd stick with something short and lowercase (e.g. {tihelper} ) Tommy Ipsen wrote:
Jochem Maas wrote:just write a wrapper (plugin) function that calls the smarty plugin which {pop_up} refers to and wraps its output with the link you want before returning the whole string. no need to prefilter.According to what I know about wrapping class methods this sounds to be a good solution! The only problem is that I have absolutely no idea how I should wrap a smarty modifier!? Can you please help with perhaps just a small code example or maybe with a link if there's anything about it it manual - though I can't find it right now! Regards, Tommy Ipsen