Re: Create wrapper for popup function with input from PEAR_QuickForm!!??

From: Date: Tue, 27 Apr 2004 13:35:05 +0000
Subject: Re: Create wrapper for popup function with input from PEAR_QuickForm!!??
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11311@lists.php.net to get a copy of this message
Hi again After reading my original (very confusing) posting and thinking more about the problem, I was able to boil it down to the following two problems: Q1: How to correctly wrap an existing smarty modifier/function with my own smarty modifier/function? A1: I've built the plugin below which is just a very "rough" solution to the problem <?php /* * Smarty plugin * -------------------------------------------------------------
* File:     function.popuphelp.php
* Type:     function
* Name:     popuphelp
* Purpose: wrapper for popup function to create customized help popup * ------------------------------------------------------------- */ function smarty_function_popuphelp($params, &$smarty) {
    $popuplinktxt = '<a href="/admin/helppopup.php?id=%1$s" class="help" target="ticmshelp" onclick="link_popup(this);return false" %2$s>%3$s</a>';
    if (!in_array('header', array_keys($params))) {
        $params['header'] = '';
    }
    if (!isset($params['helptext']) || empty($params['helptext'])) {
        $params['helptext'] = 'None';
    }
    if (!in_array('helpitem', array_keys($params))) {
        $params['helpitem'] = '';
    }
    if (!in_array('linktext', array_keys($params))) {
        $params['linktext'] = 'LINK';
    }
    $popupparams = array('delay' => '400', 'left' => yes, 'offsetx' => 10, 'offsety' => 0, 'caption' => $params['header'], 'text' => $params['helptext']);
    $popuptxt = smarty_function_popup3($popupparams, $smarty);
    return sprintf($popuplinktxt, $params['helpitem'],$popuptxt, $params['linktext']);
} function smarty_function_popup3($params, &$smarty) { ...all the code from smarty_function_popup copy/pasted... } This is not very nice, but it's working - I can think of several problems with the above method but I really can't figure out how to this "correctly" ? Q2. How to correctly pass array variables as input for a modifier/function? A2: I've read the SmartyFAQ at http://smarty.incutio.com/?page=SmartyFrequentlyAskedQuestions#template-5 and stumbled upon the use of the backtick operator (`) which seems to solve my problem: var1="$form.title.label" Is this the correct way of solving this problem? Hope you can help me out with this simplified version of the original problem! Cheers, Tommy Ipsen

« previous php.smarty.general (#11311) next »