6.5 News Listings
HTML-news_listings.tpl.php provides an item listing of the latest news items (from the News Content Type). You can choose to create a News Listing page that:
- provides the given or generated abstract
- provides the date of publication
- provides a thumbnail of an image within the News item.
You should put your different news listings (e.g. Home Page News Listing Block and Full Width News Listing Page) into different <div> and style them appropriately.
To turn a template into a news listing page, you will need to use the following snippet:
<?php
$news_listings_limit = $siteConfig['news_listings_limit'];
$default_char_limit = $siteConfig['default_char_limit'];
$lang = $item_meta['language_id'];
$format_type = $siteConfig['vis_date_format_med'];
$datelang = ""; // Goes into format Date language_id
include "templateincludes/news_listing.inc.php";
?>
“$news_listings_limit” determines how many News Items are listed on the news listings page. Setting this to ‘0’ will list all news items.
“$default_char_limit” determines the maximum amount of characters to be used as
abstract extracted from the full article (only when no abstract is specified in the News Item). Setting this to 0 will return no abstract (only when no abstract is specified in the News Item).
“$format_type” determines how the dates will be formatted (e.g. DD/MM/YY) in the news listings. Note - “$format_type” must be in a MySQL Date format.
The snippet will return News in the following format:
<div class="newsArticle">
<div class="newsTitle">
<h2><a href="/?cID=">News Item</a></h2>
<p class="subtext">dd MM YYYY</p>
</div>
<div class="newsThumb">
<p></p>
</div>
5.5.1 Adding Menu item-less (“orphaned”) News Items
You might want to create a small button on your page that links directly to creating a new News Item. In order to do this, you must add the following piece of code to your news listings template.
<a href="#" onclick="openPopup('cmspopouts/createcontent.php?radio_contentType=news&get_cID=<?php echo $_GET["cID"]?>&submit=Create...');">
Add News Item without Menu
</a>
Now, instead of using the Menu system to add a News Item, you can just go to your News Listing page, and click the new hyperlink.
You can of course add an <img> as your hyperlink rather than the given text.
Top of Page