Search code examples
smarty

smarty - copy variable and add it to another


I am using smarty and have a fairly simple question that I just don't know the correct terminology to find the answer for.

I am trying to make so that my meta description is a combination of two variables.

{$product.descr|cat:" Learn More about:"|cat:$product.fulldescr}

The above code works, but I need to use the "|replace" function on the second variable but not the first one.

So, I think I would want something like this:

{assign var='fulldescr-changed' value=$product.fulldescr|replace 'x':'y'}

{$product.descr|cat:" Learn More about:"|cat:$fulldescr-changed}"

This does not work though and I am not sure what I am doing wrong. Any thoughts would be appreciated.


Solution

  • You forgot a colon after replace. Also I would not use a hyphen in the name of the variable:

    {assign var='fulldescr_changed' value=$product.fulldescr|replace:'x':'y'}