---------------------------------------------------------------------
Hi all,
I want to share some tricks used for make easy life to my editors and also for create standard formatted news article without pain. A lot of following work comes from various post of this forum (many thanks to all contributors)
First of all I want to show the result of my work, "next 5 upcoming events" news summary template, based on current date (in my example 31/12/2008).
Summary Template
Detail template:
Where are the tricks?
* The thumbnail images in news summary template are taken from a news field.
* The same field is used inside news detail page (placed on top right) but with bigger size.
* The summaries (of news summary template) are taken from the news content (first 140 chars).
* All img ALT tags are generated from article name (not nice I know)
* Editors can create a news article without inserting/resizing images in TinyMCE and without worries about ALT tags
* No need of creating summaries.
* All articles published in standard ways with standard images size
Here tools needed:
* News module (if you want "next upcoming event" feature just apply my "period" patch)
* Plugin dynresize (to install in /plugin directory)
Here the steps for this task
1) Create a new field in news (file type) with a smart name i.e. "img_news_max_width_300px"
2) Create two new templates:
the First is summary_template:
Code: Select all
<div class="NewsSummary">
{foreach from=$items item=entry}
<div class="NewsSummaryArticle">
{if isset($entry->fields)}
{if $entry->fields|@count>0}
{foreach from=$entry->fields item='field'}
{if $field->name == 'img_news_max_width_300px' && $field->value!=''}
{assign var='loc' value=$entry->file_location}
{assign var='theFile' value=$field->value}
{capture name=some_content assign="imgName"}{dynresize path=$loc|cat:'/'|cat:$theFile width='90' alt=$entry->title|escape:htmlall}{/capture}
{assign var=title value=$entry->title|escape:htmlall}
{$imgName|replace:"/>":" alt=\"$title\" />"}
{/if}
{/foreach}
{else}
<img src="uploads/images/no_img.gif" alt="No images for this article" />
{/if}
{/if}
<strong>{$entry->postdate|date_format:"%d/%m/%Y"} - {$entry->title}</strong>
<br />
<div class="NewsSummarySummary">
{$entry->content|strip_tags|truncate:140}
</div>
<div class="NewsSummaryMorelink">
[{$entry->morelink}]
</div>
</div>
{/foreach}
</div>
Code: Select all
{assign var="pagetitle" value=$entry->title}
<div class="NewsDetail">
<h3 id="NewsPostDetailTitle">{$entry->postdate|date_format:"%d/%m/%Y"}:
{$entry->title}</h3>
{if isset($entry->fields)}
{if $entry->fields|@count>0}
{foreach from=$entry->fields item='field'}
{if $field->name == 'img_news_max_width_300px' && $field->value!=''}
{assign var='loc' value=$entry->file_location}
{assign var='theFile' value=$field->value}
{capture name=some_content assign="imgName"}{dynresize path=$loc|cat:'/'|cat:$theFile width='300' alt=$entry->title|escape:htmlall}{/capture}
{assign var=title value=$entry->title|escape:htmlall}
{$imgName|replace:"/>":" alt=\"$title\" />"}
{/if}
{/foreach}
{/if}
{/if}
<div id="NewsPostDetailContent">
{eval var=$entry->content}
</div>
</div>
You can call your news template with this code:
Code: Select all
{capture assign='currentdate'}{current_date format="%F" }{/capture}
{CGFeedMaker action='rsslink' feed='your_feed_name_here text=' ' image='/images/cms/RSS_feed.png'}
Here your news title <br />
{news category="your_category_name_here" sortasc="true" startperiod=$currentdate number="5" summarytemplate="summary_template" detailtemplate="detail_template"}
Waiting for your reply
regards
blast.
P.S. All pictures in example are property of respective owners (random pictures taken from google images)