I have a php array named consolidatedReviewData
, which looks like this:
Array
(
[consolidatedData] => Array
(
[0] => Array
(
[a_productidentification] => 5920
[avg_rating] => 4.0000
[no_reviews] => 2
)
)
)
and I am assigning it to a smarty variable like this:
self::$smarty->assign('cosolidatedReviews', $consolidatedReviewData);
Now, my question is how do I directly access avg_rating
inside the .tpl?
Something like:
{$consolidatedReviewData->consolidatedData->0->avg_rating}
Use dots to access array items:
{$consolidatedReviews.consolidatedData.0.avg_rating}
This is the same as the following in PHP:
echo $consolidatedReviews['consolidatedData'][0]['avg_rating'];
->
is for accessing object properties.
See http://www.smarty.net/docs/en/language.syntax.variables.tpl