日期:2014-05-17 浏览次数:20693 次
//当月天数循环(比如现在是6月就是30天)
{section name=d loop=$dayofmonth}
//数据库查出的数据记录循环
{section name=e loop=$events}
//如果数据库查出的记录的日期(天day)==循环的当月天数执行如下显示
{if ($events[e].event_starttime|date_format:"%d") == ($smarty.section.d.index+1)}
<td class="date_pic"><span class="date_number">{$events[e].event_starttime|date_format:"%d"}</span>
<div class="date_list">
<ul>
<li>
<a href="./events.php?eid={$events[e].eid}" target="_blank">{$events[e].event_name}</a>
</li>
</ul>
</div>
<a href="./events.php?eid={$events[e].eid}" target="_blank">
<img width="129" height="129" src="./Uploads/{$events[e].event_poster}">
</a>
</td>
{/if}
{/section}
//[color=#FF0000]问题现在就在这里,下面的条件3,4,6,11,12就是我从数据库查出数据的天(day),[color=#00FF00]为了不重复输出[/color],我写了下面的if判断,问题是我的月份是变化的,所以数据库查找出来的数据也是变化的,所以不可能每个月都是3,4,6,11,12。要根据数据库的数据改变,所以我的想法是下面这个if怎么改写?smarty模板里的if条件能循环?或者有其他思路?各位大虾帮忙,想了一天了[/color]
{if (($smarty.section.d.index+1) != 3)&&
(($smarty.section.d.index+1) != 4)&&
(($smarty.section.d.index+1) != 6)&&
(($smarty.section.d.index+1) != 11)&&
(($smarty.section.d.index+1) != 12)}
<td class="" style="cursor:auto;"><span class="date_number">{$smarty.section.d.index+1}</span> </td>
{/if}
//7天换一行
{if ($smarty.section.d.index+$day1ofweek+1)%7==0}
</tr>
{/if}
{/section}
id date data
1 2012-06-01 none
2 2012-06-02 good
3 2012-07-05 true