|
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 |
Oni81 Smarty n00b
Joined: 18 Oct 2013 Posts: 2
|
Posted: Fri Oct 18, 2013 12:06 pm Post subject: Kalenderwochen in for schleife |
|
|
Hallo Zusammen,
ich bin noch ein ziemlicher smarty Neuling und versuche mein Glück im Umgang damit.
Ich versuche die Kalenderwochen entsprechend einer Monatsansicht in einem Kalender darzustellen. Die Werte $num (Tage), $month und $year habe ich schon. Ebenso einen Timestamp. Meine Frage ist, wie kann ich mit den Werten mit Smarty Syntax eine Sinnvolle Abfrage bauen um mir die Kalenderwochen ausgeben zu lassen?
Ich habe das ganze in der oberen Hälfte einmal mit PHP gemacht. Das hilft mir aber bei den Wochentagen nicht. Die Kalenderwochen sollen nur in der Ersten Spalte, also der Montagsspalte ausgegeben und entsprechend hochgezählt werden.
Mein Quelltext sieht wie folgend aus:
Code: |
{include file="head.tpl"}
{php}
global $cfg, $usr, $db, $ci, $rights, $lang, $row, $controll;
{/php}
<br />
<br />
<div class="head_position">
<div class="cal_head">
<table width="100%" class="bigbox_ver_head">
<tr>
<td align="center" width="350">
{php}echo $lang['cal.sentence']{/php}
</td>
</tr>
<tr>
<td align="center" class="dunkler">
für den {$monthname} {$year}
</td>
</tr>
</table>
</div>
</br>
<div class="cal_pic">
<img src="img/cal_big.png">
</div>
</div>
<table cellpadding="0" cellspacing="8" id="month-selector">
<tr>
<td class="dead_art" align="center" style="width:168px;">
<table>
<tr>
<td heigh="22" colspan="3">Einstellungen</td>
</tr>
<tr>
<form method="post" action="calendar.php?act=intervall">
<td height="22">
<input type="text" class="inp25" onchange="this.form.submit();" name="inter" value="{$time}" />
</td>
</form>
<td height="22">
{php}echo $lang['cal.int']{/php}
</td>
<form method="post" action="calendar.php?act=checkbox&field=active">
<td height="22" align="right">
<input {$checkedDates} type="checkbox" value="X" onchange="this.form.submit();" name="active" />
</td>
</form>
</tr>
<tr>
<form method="post" action="calendar.php?act=show">
<td height="22" colspan="3">
<select class="inp120" onchange="this.form.submit();" name="month">
{foreach key=cid item=con from=$jahr}
{assign var="iterateDate" value=$con[0]|cat:"_"|cat:$con[1]}
<option {if $iterateDate eq $currentDateFilter} selected {/if} value="{$con[0]}_{$con[1]}">{$con[3]} {$con[1]}</option>
{/foreach}
</select>
</td>
</form>
</tr>
</table>
</td>
</tr>
</table>
<div class="t_cal">
<table cellpadding="0" cellspacing="8">
<tr>
<td class="wdays" align="center">
{php}echo $lang['cal.monday']{/php}
</td>
<td class="wdays" align="center">
{php}echo $lang['cal.tuesday']{/php}
</td>
<td class="wdays" align="center">
{php}echo $lang['cal.wednesday']{/php}
</td>
<td class="wdays" align="center">
{php}echo $lang['cal.thursday']{/php}
</td>
<td class="wdays" align="center">
{php}echo $lang['cal.friday']{/php}
</td>
<td class="wend" align="center">
{php}echo $lang['cal.saturday']{/php}
</td>
<td class="wend" align="center">
{php}echo $lang['cal.sunday']{/php}
</td>
</tr>
{section name=a start=1 loop=$first_day step=1}
{if $smarty.section.a.index eq 1 }
<tr>
{/if}
<td class="days_of_other_month" align="center">
<table width="100%">
<tr>
{if $smarty.section.a.index eq 1 }
<td align="left" height="22">
{php}
$monat = date("m");
$jahr = date("Y");
$kw_timestamp = mktime(0, 0, 0, $monat, 0, $jahr);
$kw = date("W", $kw_timestamp);
echo $kw;
{/php}
</td>
{/if}
<td align="center" height="22"> </td>
<td colspan="2" class="cal_text" height="22">
<a href="#"> </a>
</td>
</tr>
<tr>
<td align="center" height="22"> </td>
<td colspan="2" class="cal_text" height="22">
<a href="#"> </a>
</td>
</tr>
<tr>
<td align="center" height="22"> </td>
<td colspan="2" class="cal_text" height="22">
<a href="#"> </a>
</td>
</tr>
<tr>
<td class="more_dead" height="22">
<a href="#"></a>
</td>
<td height="22"> </td>
<td align="right"> </td>
</tr>
</table>
</td>
{/section}
{section name=b start=1 loop=$num+1 step=1}
{if $smarty.section.b.index == $w1+1 || $smarty.section.b.index == $w2+1 || $smarty.section.b.index == $w3+1 || $smarty.section.b.index == $w4+1 || $smarty.section.b.index == $w5+1 }
<tr>
{/if}
{if $smarty.section.b.index < 10}
{assign var="currentDay" value=0|cat:$smarty.section.b.index}
{else}
{assign var="currentDay" value=$smarty.section.b.index}
{/if}
{if $month < 10}
{assign var="currentMonth" value=0|cat:$month}
{else}
{assign var="currentMonth" value=$month}
{/if}
{assign var="currentDate" value=$year|cat:"-"|cat:$currentMonth|cat:"-"|cat:$currentDay}
{assign var="kwtimestamp" value=$smarty.now}
<td class="cal_days" align="center" valign="bottom">
<table width="100%">
{if $smarty.section.b.index == $w1+1 || $smarty.section.b.index == $w2+1 || $smarty.section.b.index == $w3+1 || $smarty.section.b.index == $w4+1 || $smarty.section.b.index == $w5+1 }
<tr><td>{$kw}</td></tr>
<tr><td> </td></tr>
<tr><td> </td></tr>
{/if}
{* Iterate through all timings *}
{foreach key=cid item=con from=$timingData}
{* If match then output inside day box *}
{if $con->due|date_format:"%Y-%m-%d" eq $currentDate}
<tr>
<td>
<a href="product.php?act=show&page=time&id={$con->id}">{$con->product_no} - {$con->text_de}</a>
</td>
</tr>
{/if}
{/foreach}
<tr>
<td align="right" height="22">
<strong>{$currentDay}</strong>
</td>
</tr>
</table>
</td>
{if $smarty.section.b.index == $w1 || $smarty.section.b.index == $w2 || $smarty.section.b.index == $w3 || $smarty.section.b.index == $w4 || $smarty.section.b.index == $w5 || $smarty.section.b.index == $w6 }
</tr>
{/if}
{/section}
</table>
</div>
<br />
{include file="foot.tpl"}
|
Ich komme leider nicht auf die Lösung. Hat jemand einen Tipp für mich? |
|
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
|