Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

assign object in smarty

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
kryuch
Smarty n00b


Joined: 24 Mar 2013
Posts: 1

PostPosted: Sun Mar 24, 2013 11:58 am    Post subject: assign object in smarty Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Mar 25, 2013 10:20 pm    Post subject: Reply with quote

$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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP