|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
kryuch Smarty n00b
Joined: 24 Mar 2013 Posts: 1
|
Posted: Sun Mar 24, 2013 11:58 am Post subject: assign object in smarty |
|
|
Hello.
I need to assign object in a template for the calling subtemplate but I could not it.
Now I do it
Code: |
{assign var="storeName" value="{$categories[categoryId].stores[storeId].name}"}
{assign var="storeId" value="$categories[categoryId].stores[storeId].id}"}
{assign var="storeDescription" value="$categories[categoryId].stores[storeId].description}"}
{assign var="storeAddress" value="{$categories[categoryId].stores[storeId].address}"}
{include file="show_store.tpl"}
|
and use in template show_store.tpl variables {$storeName}, {$storeId} and etc
but my be I can assign full object {$categories[categoryId].stores[storeId] ?
I tried
Code: |
{assign var="store" value="{$categories[categoryId].stores[storeId]"}
|
but it is not work and I can not find this problem in documentation. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Mar 25, 2013 10:20 pm Post subject: |
|
|
$categories[categoryId].stores[storeId].name is not a syntax to access object properties.
Just write it as you would do in PHP. And don't use "{...}".
maybe it should have been something like
Code: | {assign var="storeName" value=$categories[categoryId]->stores[storeId]->name} |
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|