The {news} TAG loads a list of (categorized) News Items.
This TAG is normally used to display the latest News in a list, with a link to a News detail page.
The name of the template variable the value will be assigned to.
A (comma separated) list of Category IDs, that will be used when fetching News. All News linked at least to one of these Categories will be returned.
Name of the Template variable the amount of returned Items will be assigned to.
The column, the Items will be ordered by. Default is “createdate”, what should normally apply in a News System…
The order of the returned Items. Possible values are “ASC” and “DESC”.
Start Item, default is 0. Requires “end” or “limit” to be set.
Last Item, should be set when using “start” attribute.
Replaces the “start” and “end” attribute. The amount of fetched News Items.
This parameter should NOT BE used, unless you REALLY know how the News System works!
If set to “true” this will show hidden (unreleased) news as well. Default is to hide them (false).
This example loads 3 News linked to the Category 1 and/or 2.
<html> <head> <title>Fetching categorized News</title> </head> <body> {news category="1,2" limit="3" assign="currentNews"} {foreach from=$currentNews item="newsPage"} <h1>{$newsPage->getTitle()}</h1> <b>{$newsPage->getTeaser()}</b> <br> {$newsPage->getContent()} {/foreach} </body> </html>
This example loads the latest 10 News and displays them in a list with the News image (as thumbnail) including title and teaser. Click the image or the “more” link to display the full News.
<html> <head> <title>Fetching 10 latest News</title> </head> <body> <div class="news"> {news assign="currentNews" limit=10} {foreach from=$currentNews item="newsPage"} {load_item itemtype=4 id=$newsPage->getImageID() assign="newsImage"} <a href="{link item=$newsPage}" title="{$newsImage->getName()}"> <img src="{thumbnail id=$newsPage->getImageID() width="100"}" class="newsThumbnail" alt="{$newsImage->getName()}" align="left"> </a> <h1>{$newsPage->getTitle()}</h1> <p>{$newsPage->getTeaser()} <a href="{link item=$newsPage}">more</a></p> {/foreach} </div> </body> </html>