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

Smarty array

 
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 -> General
View previous topic :: View next topic  
Author Message
duffbt
Smarty n00b


Joined: 28 Aug 2013
Posts: 1

PostPosted: Fri Sep 06, 2013 3:04 pm    Post subject: Smarty array Reply with quote

Hi,

I want to show my shopping cart with smarty but nothing works.

Here my php code :
Code:

for ($i = 0 ; $i < $count; $i++) {
         
   $tpl->append('cart', $_SESSION['cart']);
}


And in my template:
Code:

{section name=cart loop=$cart}
   {$cart[cart].id}<br/>
   {$cart[cart].name}
{/section}


Someone can help me please?
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 9:49 am    Post subject: Reply with quote

If $_SESSION['cart'] already contains the required array you don't need to acces 'cart' a second time in template:

Code:
{foreach $cart as $item}
{$item.id}<br/>
{$item.name}
{/foreach}


But what does/should your php-for-loop do?

Regards
Florian
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 -> 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