|
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 |
^peta Smarty n00b
Joined: 11 Jul 2008 Posts: 4
|
Posted: Sat Jul 12, 2008 7:05 pm Post subject: Compiling the output of a own smarty plugin? |
|
|
Hello.
I've got a language engine for smarty. It's registered as a default smarty plugin, and it is used as well.
Actually there is a problem that I want use "smarty-variables" in the output of this language-plugin.
Calling the plugin: {lang item='start.welcoming'}
Output: Welcome {$name}!
Requested output (if the smarty-variable is assigned): Welcome Kasi!
Well, i hope you was able to understand my troubles.
If there is a possibility, i'd prefer a solution like
(plugins output:) return $smarty->compile($report);
Thanks for your dedication |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sat Jul 12, 2008 11:18 pm Post subject: |
|
|
Maybe have a look in the source of the {eval}-plugin.
And consider making your plugin a compiler function instead of a custom function to avoid repeated recompiling of your text strings. |
|
Back to top |
|
^peta Smarty n00b
Joined: 11 Jul 2008 Posts: 4
|
Posted: Sun Jul 13, 2008 3:59 pm Post subject: |
|
|
Hello again.
I tried using the compiler-function.
The function returns (e.g.):
return "\necho 'Welcome {$name}';";
output of the browser:
Welcome {$name}
Well, what I need to do that I get the assigned smarty-variable.?
Thank you. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Jul 14, 2008 7:50 pm Post subject: |
|
|
return "\necho 'Welcome '.$this->_tpl_vars['name'];"; |
|
Back to top |
|
^peta Smarty n00b
Joined: 11 Jul 2008 Posts: 4
|
Posted: Mon Jul 14, 2008 11:32 pm Post subject: |
|
|
Thank you.
This is an extract of my plugin. It may help any1.
Code: |
// ( ... )
if (eregi('$', $report)) {
$result=array();
while ($found = strpos($report, '$', $found)) {
$found++;
$result[]=substr($report, $found, strpos($report, ' ', $found)-$found);
}
foreach ($result as $value) {
if (isset($smarty->_tpl_vars[$value])) {
$report=str_replace('$'.$value, '\'.$this->_tpl_vars[\''.$value.'\'].\'', $report);
}
}
}
// ( ... )
?> |
|
|
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
|