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

Calendar weeks at loop

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


Joined: 18 Oct 2013
Posts: 2

PostPosted: Fri Oct 18, 2013 1:22 pm    Post subject: Calendar weeks at loop Reply with quote

Hello together,

i have a problem with my template. I used to get the calendar weeks on each week, with the display only at monday.
I tried to get it with smarty. I got it at php with no problem, but i didnt know the syntax with smarty so i hope i got your help with it.

This is my code at the moment:
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}&nbsp;{$year}
                </td>
            </tr>
        </table>
    </div>
    </br>
    <div class="cal_pic">
        &nbsp;&nbsp;<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">&nbsp;</td>
                            <td colspan="2" class="cal_text" height="22">
                                <a href="#">&nbsp;</a>
                            </td>
                        </tr>
                        <tr>
                            <td align="center" height="22">&nbsp;</td>
                            <td colspan="2" class="cal_text" height="22">
                                <a href="#">&nbsp;</a>
                            </td>
                        </tr>
                        <tr>
                            <td align="center" height="22">&nbsp;</td>
                            <td colspan="2" class="cal_text" height="22">
                                <a href="#">&nbsp;</a>
                            </td>
                        </tr>
                        <tr>
                            <td class="more_dead" height="22">
                                <a href="#"></a>
                            </td>
                            <td height="22">&nbsp;</td>
                            <td align="right">&nbsp;&nbsp;</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>&nbsp;</td></tr>
                                <tr><td>&nbsp;</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"}


I´ll try to get the calendar week at this point:
{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>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
{/if}

how can i get it within the loop to get it only one time at each weak and not at every day?

Many thanks for your help.
[/code]
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