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

How can i do this with smarty?

 
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
sunlord
Smarty n00b


Joined: 28 Mar 2004
Posts: 3

PostPosted: Sun Mar 28, 2004 1:51 am    Post subject: How can i do this with smarty? Reply with quote

How can i do the below in smarty? Embarassed
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
View user's profile Send private message
ShenKong
Smarty Rookie


Joined: 20 Jan 2004
Posts: 27

PostPosted: Sun Mar 28, 2004 12:49 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Mar 29, 2004 7:12 am    Post subject: Re: How can i do this with smarty? Reply with quote

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 Smile 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
View user's profile Send private message
sunlord
Smarty n00b


Joined: 28 Mar 2004
Posts: 3

PostPosted: Mon Mar 29, 2004 9:25 am    Post subject: Reply with quote

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