Latest Register Log In

+ Advanced Search

Template RSS Parser

Template RSS Parser
By
20/03/11 (Edited 03/02/14)

Suppose there's a news ticker or some other sort of RSS feed that you want to display information from on your WSN site. You don't want to add its contents into your directory as listings (if you do go here instead) nor associate it to a particular listing in your directory (if you do go here instead). You just want an easy way to display the feed contents somewhere, such as WSN's front page for example.

You can accomplish that with a special template syntax. It's best understood by example, so here's an example for displaying the latest from the WebmasterSite.net links directory:
<!-- BEGIN http://links.webmastersite.net/rssfeed.php RSS -->
<p>WebmasterSite.net links directory updates:</p>
<!-- BEGIN ROW -->
From {RSSDATE}:<br >
<a href="{RSSLINK}">{RSSTITLE}</a> - {RSSDESCRIPTION}<br >
<!-- END ROW -->
<!-- END http://links.webmastersite.net/rssfeed.php RSS -->


Any field within the RSS feed can be accessed with {RSS + FIELDNAME + }. Be sure to capitalize the field name. In addition to those direct-from-feed fields, there are several template variables WSN generates for you that interpret the feed data:
{RSSDATE} - The pubDate from the feed re-parsed into your own standard date format. You can pass a custom date format as a parameter.
{RSSDESCRIPTION} - The description or text.
-- Optional parameter: number of characters. For example {RSSDESCRIPTION[100]} shortens description to 100 characters.
{RSSDESCRIPTIONSTRIPPED} - The description or text, with all HTML removed.
-- Optional parameter: number of characters. For example {RSSDESCRIPTION[100]} shortens description to 100 characters.
{RSSLINK} - The URL to link to.
{RSSTITLE} - The title of the article.

The feed data is cached every 30 minutes to keep it from slowing down your site. Note that the cached data is written to the /cache/ subdirectory and is cleared when you clear the cache on the Admin -> Maintenance -> Regenerate page... except in versions older than WSN 9.0 it's in the /feedcaches/ subdirectory instead.




Description Call in data to any spot in any template from any RSS feed URL on the internet.
Rating
Views 494 views. Averaging 0 views per day.
Similar Listings