https://www.icyphoenix.com/viewtopic.php?f=35&t=5227
-----------------------------------
Sarakin
Mon 29 Dec, 2008 20:17

[Ratings Block MOD] How To Make Loopings In PHPbb-Icy?
-----------------------------------
Hi to all. I'm back since long time searching over there. I'd like to see if you're able to save our big Achilles heel: the PHPbb loopings, you know, those things like this <!-- BEGIN loop y END loop-->. So, I'll try to explain an example about something I talked about sometime before, concretly about a Ranking with the best valued topics from the Icy application to do that (the stars one).

One example about what we understand as a Looping is to take some results from a SQL query and print them, in this case the Icy Topic Ratings which are higher than 9 points (four stars and a half).

1. We select all post which are higher or equal to 9 points (all of PHP should be in the PHP file of the Icy Block we want to make)
[code linenumbers=false]
$sql = "SELECT topic_title,topic_views,topic_rating
	FROM `ip_topics` 
	WHERE `topic_rating` >= 9";[/code]

2. We execute the query:
[code linenumbers=false]if ( !($result = $db->sql_query($sql)) )  
{  
   message_die(GENERAL_ERROR, 'Could not obtain information', '', __LINE__, __FILE__, $sql);  
} [/code]

3. We store every topic in variables in order to use them on the template and we define TEST as the Looping name:

[code linenumbers=false]while($row = $db->sql_fetchrow($result))  
{
   $template->assign_block_vars('test', array(  
   	'TOPIC_TITLE' => $row['topic_title'],  
	'TOPIC_VIEWS' => $row['topic_views'],
	'TOPIC_RATING' => $row['topic_rating']
   )); 
}[/code]

4. With this, we've just got out array full with every topic which got a Rating higher than 9, so now we should to walk around all results in our template in order to print them on the screen, and we guess we should do it by this way:

[code linenumbers=false]<!-- BEGIN test -->
{test.TOPIC_TITLE}
{test.TOPIC_VIEWS}
{test.TOPIC_RATING}
<!-- END test -->[/code]

This is because we've seen several examples in Icy which they make this way, BUT... ours doesn't work!  :cry: And we don't know why nor what part is failing. We just want to dominate the Looping in order to customize Icy a lot, adding new features to it, so we'll thank everyone who could help us and throw us a wire. Mighty Gorgon, save us, please!

Thanks for our attention in advance and Till nex time!


