|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
sunlord Smarty n00b
Joined: 28 Mar 2004 Posts: 3
|
Posted: Sun Mar 28, 2004 1:51 am Post subject: How can i do this with smarty? |
|
|
How can i do the below in smarty?
Code: |
for($i = 0; $i < $total_series; $i++)
{
$series_link = '<span class="gensmall"><a href="series.php?series="' . $seriesrow[$i]['series_list_id'] . '"&filter=0">' . $seriesrow[$i]['series_title'] . '</a> <i>('.$seriesrow[$i]['series_count'].')</i><br></span>';
if ($i == floor($total_series / 4) || $i == floor((2*$total_series) / 4 ) || $i == floor((3*$total_series) / 4))
{
$series_link .= '</td><td width="25%" valign="top" nowrap="nowrap">';
}
|
|
|
Back to top |
|
ShenKong Smarty Rookie
Joined: 20 Jan 2004 Posts: 27
|
Posted: Sun Mar 28, 2004 12:49 pm Post subject: |
|
|
I think you can use array like this :
$series_link[$i]
and use foreach in tpl file . _________________ Something comes soon ...
http://www.showtop.net
http://www.openphp.cn |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Mon Mar 29, 2004 7:12 am Post subject: Re: How can i do this with smarty? |
|
|
Code: |
{section loop=$seriesrow name=i}
<span class="gensmall"><a href="series.php?series="{$seriesrow[i].series_list_id}&filter=0">{$seriesrow[i].series_title}</a> <i>({$seriesrow[i].series_count})</i><br>
</span>
{assign var=$i value=$smarty.section.i.iteration}
{if ($i == floor($total_series / 4) || $i == floor((2*$total_series) / 4 ) || $i == floor((3*$total_series) / 4))}
</td><td width="25%" valign="top" nowrap="nowrap">
{/if}
{/section}
|
I'm not sure what you are doing there, but you notice that I assign $i only to save typing in the if statement Check the docs for section and you will see that there are several special properties that you can use to gauge where you are in a loop. |
|
Back to top |
|
sunlord Smarty n00b
Joined: 28 Mar 2004 Posts: 3
|
Posted: Mon Mar 29, 2004 9:25 am Post subject: |
|
|
Well i was using that to generate 4 cols of links... I converted it to a forech and made another post on it... But I've could never get it to divide right |
|
Back to top |
|
|
|
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
|