Last active
November 9, 2017 14:08
-
-
Save s4l1h/3e6ac443e2c65d16e52f3fbc99ac52fa to your computer and use it in GitHub Desktop.
Smarty call_user_func
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // file : /smartyplugins/function.run.php | |
| function smarty_function_run($params, $template) | |
| { | |
| //var_dump($params); | |
| if ($params['method'] == '') { | |
| trigger_error("url: run Komutunda method parametresi boş olamaz."); | |
| return; | |
| } | |
| call_user_func($params['method'],array()); | |
| //print_r($template); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require '../smarty/libs/Smarty.class.php'; | |
| //require '../smartyold/Smarty-3.0.9/libs/Smarty.class.php'; | |
| $smarty = new Smarty; | |
| define('DS', DIRECTORY_SEPARATOR); | |
| define('root_dir', DIRNAME(__FILE__) . DS); | |
| $smarty->force_compile = true; | |
| $smarty->debugging = true; | |
| $smarty->caching = false; | |
| $smarty->addPluginsDir(root_dir.'smartyplugins'); | |
| function addVariable() | |
| { | |
| global $smarty; | |
| $smarty->assign("variable", "from run"); | |
| # code... | |
| } | |
| $smarty->display('index.tpl'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| variable is : {var_dump($variable)} | |
| after call run | |
| {*call_user_func("addVariable",array())*} | |
| {run method="addVariable"} | |
| variable is : {var_dump($variable)} | |
| templates/index.tpl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment