|
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 |
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue May 13, 2003 9:22 am Post subject: |
|
|
it doesn't work in 2.4.2 (as do backticks neither), but it works in 2.5.0 . |
|
Back to top |
|
Budda Smarty Regular
Joined: 19 Apr 2003 Posts: 53 Location: Lymm, Cheshire. UK
|
Posted: Tue May 13, 2003 9:33 am Post subject: oops! |
|
|
I could have swore I'd updated Smarty before Easter! But upon rechecking the Smarty.clas.php I found
Code: | * @package Smarty
* @version 2.4.2 |
hehe. Sorry guys. |
|
Back to top |
|
sergioabreu Smarty n00b
Joined: 05 Sep 2013 Posts: 1
|
Posted: Thu Sep 05, 2013 5:42 pm Post subject: I wrote a function to concatenate in smarty. |
|
|
I've just written a function to concatenate texts in Smarty in a easy way.
First of all, you have to configure security to allow smarty using functions.
Declare this function in a php file that is loaded before invoking the template.
Code: |
<?php
/**
* Smarty Concat. A php function that concatenates flexible length of parameters in Smarty.
* The first param is a Smarty variable to hold the result.
* From the second parameter till the last one they will be concatenated, and assigned automatically to the first parameter.
* CREDITS: Sergio Abreu
* http://sites.sitesbr.net
*/
function smartyconcat( &$res ){
$args = func_get_args();
for( $i=1; $i < count($args); $i++){
$s .= $args[$i];
}
$res = $s;
}
?>
|
Usage:
Remember, the first parameter is the variable that will receive the concatenated result. Only the arguments at the right of the function will be concatenated (from the 2nd on).
{$myStr|smartyconcat:"one text":$one_variable:"other text":$anotherVariable}
After somewhere in the code you want to show it, just use:
{$myStr} |
|
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
|