smarty assinging variable
I am trying to assing a variable in my .tpl by doing this,
{assign var="image" value="images/stores/{$location.storename|regex_replace:"/[' ']/":"-"|lower}.jpg"}
however I am getting this error,
Smarty error: [in stores/view-store.tpl line 135]: syntax error: invalid attribute name: '|lower'
How Can i stop this error but still drop the casing of the r开发者_JAVA百科eturned info to lowercase?
Even if you take lower off you're still going to have problems. You can't have a {} block inside a {} block. Nor can you have "" nested in "".
http://www.smarty.net/docsv2/en/language.custom.functions.tpl#language.function.assign
Look at that page, check out the complex example. You'll use something like
{assign var="image" value=``}
This might also be useful for you:
http://www.smarty.net/docs/en/language.function.eval.tpl
Ultimately though, you should be doing that on the PHP side, logic and code is not meant to be in the template unless there really is no other choice.
精彩评论