Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Append array and access as nested array

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
IT_Services
Smarty Rookie


Joined: 30 Sep 2013
Posts: 9

PostPosted: Mon Sep 30, 2013 7:01 am    Post subject: Append array and access as nested array Reply with quote

Hi,

I want to dynamically add key-value-arrays to a variable and access them in the template like this:

{$User.IsAuthenticated}
{$User.DisplayName}

In my code the variable should be filled on different places:

$Template->append('User' => array('IsAuthenticated' => $Authentication->IsUserAuthenticated()));
...
$Template->append('User.AllowThis', false);
...
$Template->append('User.AllowThat', true);

But I don't know how to assign/append the values, that I can access them in the template like the way I want.

Regards
Florian
Back to top
View user's profile Send private message
IT_Services
Smarty Rookie


Joined: 30 Sep 2013
Posts: 9

PostPosted: Mon Sep 30, 2013 12:17 pm    Post subject: Reply with quote

Solution found:
The append-function offers a 3rd parameter ("merge") - set to true I get the expected result
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General 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