Skip to main content

Smarty

12th October, 2022

Updated: 12th October, 2022

    Adding days etc to a smarty variable

    {$item_data.course_date|date_format:"%d/%m/%Y"}
    {assign var='courseDate' value=$item_data.course_date}
    {math equation="x + y" x=$courseDate|strtotime y=172800 assign="courseDate2"}
    ```### 3 col table
    
    ```sh
    <tr class="">
                        <table border="0" width="100%" cellspacing="0" cellpadding="0">
                        {if $records}
                            <tr>
                            {*work out how many extra columns we need to make to ensure IE doesn't fall over*}
                            {math assign="colsRemaining" equation="3 - (count % 3)" count=$records|@count}
                            {foreach from=$records item=value name=foo}
    
                                    {*{$smarty.foreach.foo.iteration is div by 3}*}
                                    {*{$smarty.foreach.foo.index}*}
                                    <td width="33%" valign="top" class=" border_productsList_row {if $smarty.foreach.foo.index mod 3} border_productsList_item_left{/if}">
                                        ...
                                    </td>
    
                                {if $smarty.foreach.foo.iteration is div by 3}
                                    </tr><tr>
                                {/if}
    
                            {/foreach}
    
    
                                {*display eextra cols*}
                            {if $colsRemaining < 3}
                                {section name=padding loop=$colsRemaining}
                                    <td width="33%" valign="top" {if $smarty.section.padding.index mod 3} class="border_productsList_item_left" {/if}>
                                        &nbsp;
                                    </td>
                                    {if $smarty.section.padding.iteration is div by 3}
                                    </tr><tr>
                                    {/if}
                                {/section}
    
                            {/if}
    
    
                            </tr>
                            {else}
                            <tr>
                            <td  valign="middle" align="center"class="border_foruntitlebar_skyblue" height="100px">
                                <span class="dynamic_titaltxt"> {$messages.msg_no_record_found} </span>
                            </td>
                            </tr>
                        {/if}
    
    
                        </table>

    four col alphabetical table

    <div id="accordion" class="panel-group">
                <div class="list-group ">
                        {assign var=cnt value='0'}
                        {assign var=cnt2 value='0'}
                        {if $alphabet}
                        <div class="list-group-item">
                            <table width="100%" cellspacing="0" cellpadding="0"><tr>
                                {foreach from=$alphabet key=k item=v}
                                    {if $cnt eq 4} {assign var=cnt value='1'} </tr><tr>
                                        <td width="22%"  style="align:center"  valign="middle" class="">
                                            <a class="btn {if $sortByKey eq $k}btn-primary{/if} {if $keys.$cnt2.count_records eq '0'}disabled{/if} btn-default btn-block w90p mtb5"
                                                   href="/download/alpha/{$v}">
                                            <small><strong style="text-transform: uppercase">{$v}</strong> ({$keys.$cnt2.count_records})</small></a>
                                        {else}{assign var=cnt value=$cnt+1}
                                        <td width="22%"   style="align:center"  valign="middle" ><a href="javascript:setAlpha('{$k}');"  >
                                        <a class="btn {if $sortByKey eq $k}btn-primary{/if} {if $keys.$cnt2.count_records eq '0'}disabled{/if} btn-default btn-block w90p mtb5"
                                           href="/download/alpha/{$v}">
                                            <small><strong style="text-transform: uppercase">{$v}</strong> ({$keys.$cnt2.count_records})</small></a>
                                        </td>
                                    {/if}
                                    {assign var=cnt2 value=$cnt2+1}
                                {/foreach}</tr>
                            </table>
                        </div>
                        {/if}
            </div>
            </div>

    f3e7ba6a-c951-441e-a615-8677b6a5cf6c

    Created on: 12th October, 2022

    Last updated: 12th October, 2022

    Tagged With: