Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
assign object in smarty

 
Post new topic   Reply to topic    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: 4669
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:   
Post new topic   Reply to topic    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