Hi,
I have a question, I have a created a Smarty Block in CS Cart, which contains a Smarty variable {$test}. The content of this variable is something like
"This is an test, where I show a variable test_content: {$test_content}."
The problem is that {$test_content} is displayed literally. I have tried using something like
{$test|replace:"{$test_content}":$test_content} but the string is not being replaced. Probably because {$test_content} is seen as a variable in the replace statement.
Anyone out there who know how to solve this problem?
Thanks in advance!
Allan
Use another placeholder in the value of the variable. E.g.
Some text [CONTENT] lorem ipsum
Then use
{$test|replace:"[CONTENT]":$test_content}
Another alternative when your string is literal string like your example:
{assign var="test" value="This is an test, where I show a variable test_content: `$test_content`."}
Then use as:
Here is the result: {$test}
The approach Ecom has used works best when your string is actually a language variable (better practice) rather than a literal string. I.e. the code could then look like (I prefer str_replace rather than the built in smarty replace - there are always different ways):
{"[CONTENT]"|str_replace:$test_content:__("my_lang_variable")}
hi all,
I tried to do above mentioned problem so I have implemented in following, you can use if you think it is correct.
For this set language in language translation.
Language variable : content
value: [content]
{assign var=test value="NEW TEXT"}
{assign var=demo value=“Hello how are you {__(“content”, [”[content]" => $test ] )}"}
{$demo}
The output will be
"Hello how are you NEW TEXT"
In this I have used both smarty and cs-cart language feature.
But this will work only when working in cs-cart.
-Himanshu Dangwal
Thanks all for replying, i've made use of EcomLabs' solution.