Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Brautkleider auf Topwedding.de

Find free files to download on allwhatyouwant.net

Looking For Affordable Wedding Dresses 2015 at Best Prices On TDBridal.com

Shop high quality cheap prom dresses on Dresswe.co.uk

Buy New Arrival Cheap Prom Dresses 2015 at JDBRIDAL Prom Dress Store

Advertisement

Name

registerDefaultPluginHandler() 鈥 娉ㄥ唽榛樿鎻掍欢澶勭悊鍣

璇存槑

void聽registerDefaultPluginHandler(mixed聽callback);

娉ㄥ唽涓涓粯璁ょ殑鎻掍欢澶勭悊鍣紝褰撶紪璇戠▼搴忔棤娉曟壘鍒版ā鏉夸腑鏍囩瀹氫箟鐨勬椂鍊欙紝灏嗚皟鐢ㄨ繖涓鐞嗗櫒杩涜鍥炶皟銆 鍙傛暟锛

  • callback defines the PHP callback. it can be either:

    • A string containing the function name

    • An array of the form array(&$object, $method) with &$object being a reference to an object and $method being a string containing the method-name

    • An array of the form array($class, $method) with $class being the class name and $method being a method of the class.

褰揝marty鍦ㄧ紪璇戣繃绋嬩腑閬囧埌鏈畾涔夛紙娌℃湁娉ㄥ唽鐨勬彃浠舵垨鑰呬笉鍦ㄦ彃浠剁洰褰曚笅锛夌殑鏍囩鏃讹紝Smarty灏嗚瘯鍥捐皟鐢ㄩ粯璁ょ殑鎻掍欢澶勭悊鍣ㄦ潵澶勭悊銆 濡傛灉鏈畾涔夋爣绛炬槸鍦ㄥ惊鐜腑锛屽垯璇ュ鐞嗗櫒灏嗘湁鍙兘琚娆¤皟鐢ㄣ

Example聽14.38.聽榛樿鎻掍欢澶勭悊鍣ㄤ緥瀛


<?php

$smarty = new Smarty();
$smarty->registerDefaultPluginHandler('my_plugin_handler');

/**
 * 榛樿鎻掍欢澶勭悊鍣
 *
 * 褰揝marty鍦ㄧ紪璇戣繃绋嬩腑閬囧埌鏈畾涔夌殑鏍囩鏃惰皟鐢
 * 
 * @param string                     $name      鏈畾涔夋爣绛剧殑鍚嶇О
 * @param string                     $type     鏍囩绫诲瀷 (姣斿锛 Smarty::PLUGIN_FUNCTION锛孲marty::PLUGIN_BLOCK锛
                                               Smarty::PLUGIN_COMPILER锛孲marty::PLUGIN_MODIFIER锛孲marty::PLUGIN_MODIFIERCOMPILER)
 * @param Smarty_Internal_Template   $template     妯℃澘瀵硅薄
 * @param string                     &$callback    杩斿洖 鍥炶皟鍑芥暟鍚 
 * @param string                     &$script      褰撳洖璋冨嚱鏁版槸澶栭儴鐨勶紝鍙繑鍥 鍑芥暟鎵鍦ㄨ剼鏈殑璺緞銆
 * @param bool                       &$cacheable    榛樿true锛 濡傛灉鎻掍欢鏄笉鍙紦瀛樼殑璁剧疆鎴恌alse (Smarty >= 3.1.8)
 * @return bool                      鎴愬姛杩斿洖true
 */
function my_plugin_handler ($name, $type, $template, &$callback, &$script, &$cacheable)
{
    switch ($type) {
        case Smarty::PLUGIN_FUNCTION:
            switch ($name) {
                case 'scriptfunction':
                    $script = './scripts/script_function_tag.php';
                    $callback = 'default_script_function_tag';
                    return true;
                case 'localfunction':
                    $callback = 'default_local_function_tag';
                    return true;
                default:
                return false;
            }
        case Smarty::PLUGIN_COMPILER:
            switch ($name) {
                case 'scriptcompilerfunction':
                    $script = './scripts/script_compiler_function_tag.php';
                    $callback = 'default_script_compiler_function_tag';
                    return true;
                default:
                return false;
            }
        case Smarty::PLUGIN_BLOCK:
            switch ($name) {
                case 'scriptblock':
                    $script = './scripts/script_block_tag.php';
                    $callback = 'default_script_block_tag';
                    return true;
                default:
                return false;
            }
        default:
        return false;
    }
 }

?>

  

Note

鍥炶皟鏂规硶蹇呴』鏄潤鎬佺殑锛屽鍑芥暟鍚嶇О鎴栬呬竴涓寘鍚被鍜屾柟娉曞悕鐨勬暟缁勩

涓嶆敮鎸佸瀵硅薄鏂规硶绛夊姩鎬佺殑鍥炶皟銆

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 18 plus 17? (Are you human?)

Advertisement