|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Goodwill Smarty n00b
Joined: 11 Apr 2014 Posts: 1
|
Posted: Fri Apr 11, 2014 1:06 pm Post subject: registerPlugin for function/compiler different result |
|
|
Smarty 3.1.18 Smarty.class.php 4828 2014-04-04 23:38:36Z
in code:
Code: | function smarty_concat_css($arg){
print_r($arg);
}
$smarty->registerPlugin("compiler", "concat_css", "smarty_concat_css"); |
in template:
Code: | {concat_css add="shortcodes.css"} |
result:
Code: | Array
(
[add] => "shortcodes.css"
) |
For the same function using "function" plugin type
Code: | $smarty->registerPlugin("function", "concat_css", "smarty_concat_css"); |
result:
Code: | Array
(
[add] => shortcodes.css
) |
For these who dont see that, there are quotes around value for compiler plugin type. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri Apr 11, 2014 7:36 pm Post subject: |
|
|
This is not a bug.
The parameter passing is different for both cases.
A function plugin is called at run time as a function and the value of the parameters is passed.
{foo bar=$buh}
In this case the value of $buh is passed.
Compiler plugins should return valid PHP code which is inserted into the compiled template.
The passed parameter are in this case strings for insertion in the PHP code. For above example not the value of $buh is passed but the PHP code to access the variable. (its value at compile time would useless)
If you pass a string to a compiler plugin the parameter does include the quotes.
The compiler plugin can so take any parameter and insert its content in the resulting PHP code. |
|
Back to top |
|
|
|
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
|