adding content in the middle of smarty variable
how can I modify a smarty variable on tpl file and add some data after certain position without using php? is it possible?
suppose,
$var="this is test content for a variable";
and i wan开发者_StackOverflow中文版t to add "EXTRA DATA " after 8th character position so that the final output will be "this is EXTRA DATA test content for a variable"
You could do it like this:
{$var|substr:0:8}EXTRA DATA {$var|substr:8}
May I ask why you're not wanting to do this in PHP? It's more suited there, this is not the job that a template should be doing.
yes you can truncate the sentencen use http://www.smarty.net/docs/en/language.modifier.truncate.tpl
then add your extra word as smarty varible
精彩评论