RE: [SMARTY] rownum with foreach?

From: Date: Fri, 23 Aug 2002 12:32:12 +0000
Subject: RE: [SMARTY] rownum with foreach?
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5815@lists.php.net to get a copy of this message
If you know the news_id, try {foreach from=$newsListData.$news_id.comments item=comment key=comment_id} That should set $comment to the current comment (so $comment.comment_text would contain comment text), and $comment_id to the key of the array. If you don't know the news_id, loop over the $newsListData array, then for each news_id, loop through the comments: {foreach from=$newsListData item=news_item key=news_id} News Info:<br> Id {$news_id}<br> Topic: {$news_item.news_topic}<br> ... Comments: {foreach from=$news_item.comments item=comment key=comment_id} <li>{$comment_id}. $comment.text {/foreach} {/foreach} I haven't tested it, but that's the logic that comes to mind when I look at the way your array is set up. Most of the recursive looping I've done used objects, so my assoc array syntax might be messed up (critique, anyone?), but that's the basic idea the way I see it. Hope that helps :) -- Josh -----Original Message----- From: Peter Billen [mailto:peter@clueless.be] Sent: Friday, August 23, 2002 6:19 AM To: 'Smarty General' Subject: RE: [SMARTY] rownum with foreach? array $newsListData: -> ['news_id'] (x) -> ['news_topic'] -> ... -> ['comments'] (x) -> ['comment_id'] (x) -> ['comment_text'] -> ... Not good? Thanks, Peter -----Original Message----- From: Josh Johnson [mailto:mailing_lists@allusiveimage.com] Sent: donderdag 22 augustus 2002 21:49 To: peter@clueless.be Subject: RE: [SMARTY] rownum with foreach? How is your array structured? -- Josh -----Original Message----- From: Peter Billen [mailto:peter@clueless.be] Sent: Thursday, August 22, 2002 2:21 PM To: 'Smarty General' Subject: RE: [SMARTY] rownum with foreach? Nope, I already tried that, didn't work. Thanks for your input. Peter -----Original Message----- From: Josh Johnson [mailto:mailing_lists@allusiveimage.com] Sent: donderdag 22 augustus 2002 19:28 To: peter@clueless.be; 'Smarty General' Subject: RE: [SMARTY] rownum with foreach? Try changing {$smarty.foreach.comments.rownum} to {$comment_id.rownum} -- Josh -----Original Message----- From: Peter Billen [mailto:peter@clueless.be] Sent: Thursday, August 22, 2002 11:10 AM To: 'Smarty General' Subject: RE: [SMARTY] rownum with foreach? Little fuckup, sorry (read again below) Peter -----Original Message----- From: Peter Billen [mailto:peter@clueless.be] Sent: donderdag 22 augustus 2002 17:09 To: 'Smarty General' Subject: [SMARTY] rownum with foreach? Hi, Why doesnt this work? {foreach from=$newsListData.comments item=comment_id name=comments} . . . Comment #{$smarty.foreach.comments.rownum} . . . {/foreach} Thanks, Peter -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.smarty.general (#5815) next »