Jump to content

[Resolved] concatenate php variables in tpl files


overbags
 Share

Recommended Posts

hi everyone i'm trying to modify a tpl page and i have to insert in a div a text composed of several php variables

the problem is that I can't do the chaining

I post an example of how I would do it in a php file to make you understand but that in tpl it does not work

{$name_lastname = $firstname . " " . $lastname}

<div>

{$name_lastname}

</div>

I need it to result in a single variable ... I know I could do {$firstname} &nbsp; {$lastname}

Edited by overbags (see edit history)

Share this post


Link to post
Share on other sites

It is always recommended that variables of this kind be generated in the controller. To generate them in the .tpl you can try like this

{assign var='name_lastname' value="{$firstname}{' '}{$lastname}"} 

 

  • Like 1

Share this post


Link to post
Share on other sites

  • overbags changed the title to [Resolved] concatenate php variables in tpl files

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More