php - Smarty include passing array in var -


i try pass array element in include's var.

but still have error :

fatal error: uncaught --> smarty compiler: syntax error in template "file:/home/technique/www/site/tpl/home.html" on line 6 "{include file='include/article-latest.html' class='col-50' title=$article.title tag=article_category.$article.category img=$article.thumbnail view='3526' share='564'}" - unexpected ".", expected 1 of: "}" <-- thrown in /home/technique/www/common/lib/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php on line 6

my code :

{foreach $latest_article.0 $article}     {include file='include/article-latest.html' class='col-50' title=$article.title tag=article_category.$article.category img=$article.thumbnail view='3526' share='564'} {/foreach} 

apparently, problem using constant article_category. seem php constant isn't interpreted smarty...

php constants in smarty can called $smarty.const.constant_name reference here - https://www.smarty.net/forums/viewtopic.php?p=25903&sid=92c2eb2c177f8f82ae084361ee6c4400

{foreach $latest_article.0 $article}     {include file='include/article-latest.html' class='col-50' title=$article.title tag=$smarty.const.article_category.$article.category img=$article.thumbnail view='3526' share='564'} {/foreach} 

besides take account following: - title , category might constants in code therefore must called via $smarty.const.title , $smarty.const.category appropriately; - article_category constant strange used array; - article.$article.category might deep-level array , might processed smarty incorrectly (because of many dots). fix it, might need assign variables, example:

{assign var="article_category" value=$smarty.const.article_category} {foreach $latest_article.0 $article}     {include file='include/article-latest.html' class='col-50' title=$article.title tag=$article_category.$article.category img=$article.thumbnail view='3526' share='564'} {/foreach} 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -