Latest articles
Latest articles of category




Announcements.tpl


announcements.tpl and announcements_all.tpl are both related with displaying the announcement content on CMS.
An announcement is an article with limited options. You can only add a title and content on it and set that to be published or not while on article as discussed in a previous page there are many options to choose from. Over the global configuration of the administration menu there is an option to setup how many announcements you wish to be displayed on home or any other page that you've setup via templates. That limit on announcements will be served via the announcements.tpl file.
Let's say that you have published 100 announcements over the last few days and that you've configured to display the last 5 on home page. If you wish to see the rest, you need to call the announcements_all.tpl. That file will display all announcements that are published no matter the day.

Depending the pagination configuration (that also available on administration menu under global configuration) announcements will be displayed like 10 per page with link on the bottom of the page to see the page 2, page 3 etc. That is the functionality of those files. All you need to make use of them is to include the relevant file into your tpl, usually header or footer.

The code to insert a tpl is:

How to include announcements.tpl
{include file="../templates/themes/$themeName/announcements.tpl"}
Announcements.tpl
{if $countAnnouncements<1}
    <p><i>{t}There are no Announcements{/t}</i></p>
{else}
    {section name=announcements loop=$id1}
        <h3>{t}Announcement{/t}: {$titleAn[announcements]}</h3>
        <p>{$body1[announcements]}</p>
        <!--<i>({t}Posted on: {/t}{$date1[announcements]|date_format:"%d/%m/%Y"})</i>-->
        {if $admin==1}
             <a href="{$smarty.const.WEBSITE_ROOT}/cms/common/announcementsSnipet.php?id={$id1[announcements]}&action=edit&lang={$language}" rel="gb_page_fs[]">
             {t}Edit Announcement{/t}</a><br />
        {/if}
    {/section}
{/if}
Announcements_all.tpl
<!--Displays all Announcements -->
<title>{t}Announcements{/t}</title>
{if $paginate.total <1}
<p></p>
    {t}There are no Announcements{/t}!
{else}

    {section name=content loop=$results}
    <h2>{$results[content].title}</h2>
    {$results[content].body}
    <i>{t}Posted on: {/t}{$results[content].date|date_format:"%d/%m/%Y"}</i><p></p>
    {/section}
     <p></p>
    {paginate_prev} {paginate_middle format="page"} {paginate_next}
     <br />
    {if $paginate.size gt 1}
      Items {$paginate.first} - {$paginate.last} of {$paginate.total} displayed.
    {else}
      Item {$paginate.first} of {$paginate.total} displayed.
    {/if}

{/if}

<p></p>
<a href="{$smarty.const.WEBSITE_ROOT}/{$smarty.session.session_lang}/index.php">{t}Back to Home page {/t}</a>
<p></p>
Posted on: 23/03/2011