I'm hoping to only show the most recent news article on our homepage as a short snippet with xx amount of characters in the preview, but then allow them to view previous articles. My other option to edit the homepage all the time, but I'd like to use the built in News module.
Is this possible? I looked at the newsSummarypage template but was unable to determine what to change in order to get this to work. Any ideas?
Only show last news article on page
Re: Only show last news article on page
You need to read the News module help. This is very possible and very easy.
Re: Only show last news article on page
In the Module help you can find the parameter "number":
shows the last ONE news
Code: Select all
{news number="1"}
Re: Only show last news article on page
Thank you. I didn't think about using the 1. The help didn't state which 1 would be used but I guess that is based on your criteria.owr_web wrote: In the Module help you can find the parameter "number":
shows the last ONE newsCode: Select all
{news number="1"}
My goal is to get it to look like:
Our News
A Warning Shot from Mother <-- That would be article link.
The news snippet would go here and you would put what you want to. Just text Just test Just text Just test Just text Just test Just text Just test Just text Just test v v Just text Just test v v .. |READ MORE| <---- would be right next to article.
Last edited by Keithb on Thu Aug 12, 2010 1:40 pm, edited 1 time in total.
Re: Only show last news article on page
The News will always show the latest news on top or first as the case may be, so limiting it to 1 article will show the latest...
In the summary template what you show you want is some of the default template calls, so make a new one or edit the existing summary template to only have the title link div, the summary div, and the more link div, when calling the News tag use moretext='|READ MORE|' parameter...
In the summary template what you show you want is some of the default template calls, so make a new one or edit the existing summary template to only have the title link div, the summary div, and the more link div, when calling the News tag use moretext='|READ MORE|' parameter...
Re: Only show last news article on page
Here's an example. We have the last three news items, but you could narrow it to one. Then it links to the detail page. You can also provide links for folks to browse by date or by category as we have here:
http://idylwood.org/
Here's the code to pull the box into the sidebar. (We use a global content block.)
Then your detail page looks like this:
And your summary page looks like this:
And of course you create pages for the date archives and category archives:
1. Create a parent page, "News." Leave it blank (CMSMS won't let you do this so just put a space in the "content" box and save the page.
2. Create a subpage called "Date Archives" and insert this code in the content box:
3. Create a subpage called "Category Archives" and insert this code in the content box:
4. And in the News module, create a category template:
HTH. Contact me offlist if you want help with this.
http://idylwood.org/
Here's the code to pull the box into the sidebar. (We use a global content block.)
Code: Select all
<div id="news">
<h2>News</h2>
<div id="news-container">
{news number='1' summarytemplate='News Summary' detailpage='news'}
</div><!-- /news-container -->
</div><!-- /news -->
Code: Select all
<!-- Idylwood News Detail Template -->
{if $entry->formatpostdate}
<div id="NewsPostDetailDate">
{$entry->formatpostdate}
</div>
{/if}
<h3 id="NewsPostDetailTitle">{$entry->title}</h3>
<hr id="NewsPostDetailHorizRule" />
{if $entry->summary}
<div id="NewsPostDetailSummary">
<strong>
{eval var=$entry->summary}
</strong>
</div>
{/if}
{if $entry->category}
<div id="NewsPostDetailCategory">
{$category_label} {$entry->category}
</div>
{/if}
<div id="NewsPostDetailContent">
{eval var=$entry->content}
</div>
<p><a href="/news/news-archives">View all news items</a>.<br />
<a href="/news/topics">View news items by category</a>.</p>
<!-- /Idylwood News Detail Template -->
Code: Select all
<!-- Idylwood News Summary Template -->
<!-- This is what appears in the News Box on the sidebar -->
{if $pagecount > 1}
<p>
{if $pagenumber > 1}
{$firstpage} {$prevpage}
{/if}
{$pagetext} {$pagenumber} {$oftext} {$pagecount}
{if $pagenumber < $pagecount}
{$nextpage} {$lastpage}
{/if}
</p>
{/if}
{foreach from=$items item=entry}
<div class="NewsSummary">
{if $entry->formatpostdate}
<div class="NewsSummaryPostdate">
{$entry->formatpostdate}
</div>
{/if}
<div class="NewsSummaryLink">
{$entry->titlelink}
</div>
{if $entry->summary}
<div class="NewsSummarySummary">
{eval var=$entry->summary}
</div>
<div class="NewsSummaryMorelink">
[{$entry->morelink}]
</div>
{else if $entry->content}
<div class="NewsSummaryContent">
{eval var=$entry->content}
</div>
{/if}
</div>
{/foreach}
<!-- VIEW NEWS ARCHIVES -->
<p>View <a href="/news/news-archives">Date Archives</a><br />
View <a href="/news/topics">Category Archives</a></p>
<!-- FEEDBURNER LINK -->
{global_content name='news-feed'}
<!-- /Idylwood News Summary Template -->
1. Create a parent page, "News." Leave it blank (CMSMS won't let you do this so just put a space in the "content" box and save the page.
2. Create a subpage called "Date Archives" and insert this code in the content box:
Code: Select all
<h3>Browse News Archives</h3>
{news showarchive='0'}
Code: Select all
<h3>Browse News Topics</h3>
{news browsecat='1' browsecattemplate='topics'}
Code: Select all
{if $count > 0}
<ul class="topics">
{foreach from=$cats item=node}
{if $node.depth > $node.prevdepth}
{repeat string="<ul>" times=$node.depth-$node.prevdepth}
{elseif $node.depth < $node.prevdepth}
{repeat string="</li></ul>" times=$node.prevdepth-$node.depth}
</li>
{elseif $node.index > 0}</li>
{/if}
<li class="newscategory">
{if $node.count > 0}
<a href="{$node.url}">{$node.news_category_name}</a> ({$node.count}){else}<span>{$node.news_category_name} (0)</span>{/if}
{/foreach}
{repeat string="</li></ul>" times=$node.depth-1}</li>
</ul>
{/if}
<p><a href="http://feeds.feedburner.com/RssFeed-Idylwood" rel="alternate" type="application/rss+xml"><img src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0"/></a> <a href="http://feeds.feedburner.com/RssFeed-Idylwood" rel="alternate" type="application/rss+xml">Subscribe in a reader</a></p>
Submit your site to the We Love CMSMS showcase