|
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 |
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Sep 19, 2014 3:32 pm Post subject: draw current month in a table |
|
|
Smarty 3 code snippet to draw current month, highlight today:
Code: | {* draw current month, highlight today *}
{$dow = strftime('%w', strtotime('first day of this month'))} {* starting day of week *}
{$numdays = strftime('%d', strtotime('last day of this month'))} {* days in the month *}
{$today = strftime('%d')}
{$currday = 1}
<table>
<tr>
{for $x=0 to 34}
<td{if $x==$today} class="today"{/if}>{if $x >= $dow && $x <= $numdays}{$currday++}{/if}</td>
{if $x@iteration is div by 7} {* end of row, go to next row or end loop *}
{if $currday < $numdays}</tr><tr>{elseif $currday >= $numdays}{break}{/if}
{/if}
{/for}
</tr>
</table> |
stylesheet:
Code: | .today {
background-color: #7777ff;
} |
Screenshot (styling not included, do that yourself):
|
|
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
|