|
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 |
aapje Smarty Rookie
Joined: 18 May 2010 Posts: 5
|
Posted: Thu Dec 02, 2010 2:18 pm Post subject: Section index value |
|
|
Code: |
{section name=maanden start=1 loop=12 step=1}
<tr>
<td>{$smarty.section.maanden.index|date_format:"F"}</td>
</tr>
{/section}
|
Why on earth does this display:
January
January
January
January
January
January
January
January
January
January
January
Somehow it keeps using the index 1 in every loop. But when I print the index value it says 0 till 12. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Dec 02, 2010 2:29 pm Post subject: |
|
|
date_format expects a timestamp or date string, not an integer. |
|
Back to top |
|
aapje Smarty Rookie
Joined: 18 May 2010 Posts: 5
|
Posted: Thu Dec 02, 2010 2:34 pm Post subject: |
|
|
mohrt wrote: | date_format expects a timestamp or date string, not an integer. |
Facepalm, just found out myself where I was going wrong |
|
Back to top |
|
aapje Smarty Rookie
Joined: 18 May 2010 Posts: 5
|
Posted: Thu Dec 02, 2010 2:56 pm Post subject: |
|
|
If anyone needs to loop through all months of the year:
php:
Code: |
$months = array();
for ($i = 1; $i <= 12; $i++) {
$months[$i] = strftime("%B", mktime(0,0,0, $i, 1));
}
|
smarty:
Code: |
$smarty->assign("months", $months);
{foreach name=months from=$months item=month}
<tr>
<td>
{$month}
</td>
</tr>
{/foreach}
|
|
|
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
|