Warning

This document hasn't been checked for compatibility with current versions of Plone. Use at your own risk.

How To Syndicate News Items

by Frank Cohen last modified Dec 06, 2009 09:27 PM
Shows how Plone support RSS syndication, and how to add an RSS feed button to the News portlet to syndicate news items.

Plone 2 provides easy support to create RSS news feed channels from the content you publish on your Plone-based site. This how-to article describes a simple technique to provide an RSS news feed channel to the news postings on your Plone-based site.

A weblog, or blog, is a personal journal on the web. Weblogs express as many different subjects and opinions as there are people writing them. Some blogs are highly influential and have enormous readership while others are primarily intended for a close circle of family and friends. Growth of blogs has been incredible. By September 2004 Technorati tracks 4 million blogs. News readers such as NetNewsWire make it easy to keep track of news and content on dozens of Web sites you normally follow without having to take the time to visit each site individually.

Plone 2 supports RSS in at least two ways: Searches may be output into an RSS feed and most pages may be viewed as an RSS feed by using the page's alternate URL. For example, to view my blog through a browser use this URL: http://www.pushtotest.com/thecohenblog/simpleblog_view and to view the same blog as an RSS feed use http://www.pushtotest.com/thecohenblog/RSS.

You can also turn a Plone search result into an RSS feed. Enter a search term into a Plone search box and click search. The results page will include an RSS icon that is linked to the RSS feed for that search. This gives us the capability to link the news items on your site to an RSS feed. By adding search parameters for news items that have been published we now have an RSS feed to the news items on a site. For example, the RSS feed for news on the PushToTest Web site is found at http://www.pushtotest.com/search_rss?portal_type=News+Item&review_state=published.

One addition step enables the News Portlet to add an RSS icon to receive site news as an RSS feed. For an example of this look at the News Portlet at http://www.pushtotest.com. Notice the RSS icon to the right of the News tab. This is accomplished by customising the template portal_skins/plone_portlets/portlet_news.pt as such:

  <html xmlns:tal="http://xml.zope.org/namespaces/tal" 
  xmlns:metal="http://xml.zope.org/namespaces/metal"    
  i18n:domain="plone"> 
  <body>

  <!-- The news box -->

  <div metal:define-macro="portlet" 
  tal:define="results python:request.get('news',    
  here.portal_catalog.searchResults( portal_type='News Item' , 
  sort_on='Date', sort_order='reverse', review_state='published')[:5]);"
  tal:condition="python:test(template.getId()!='news' and results, 1, 0)"> 

     <div class="portlet" id="portlet-news">

     <h5 i18n:translate="box_news">News&nbsp;
     <a href="http://www.pushtotest.com/search_rss?portal_type=News+Item&review_state=published">
     <img src="http://www.pushtotest.com/rss.gif" border=0 height=16 width=16></a></h5>

     <div class="portletBody">
  . . .

The above code snipped shows the first 22 or so lines of the portlet_news.pt file. Notice the line that begins with an h5 tag. This line now includes an image icon and a link to the search for published news items. The link delivers an RSS news feed of the site's currently published news items.

Hope this helps.

Frank Cohen


Contribute

Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.