WSN Gallery
Associating an RSS Feed With a Listing
Associating an RSS Feed With a Listing
By Paul

This article is for attaching feeds to listings, and should not be confused with submitting RSS feeds seperately.

In your listings switches you have an "RSS Submissions" option. When you turn this on people will have the option to supply an RSS feed url with their submission. If they do, data from that feed will become available for the listing. (Note: As of version 5.1.0, associated feeds are automatically detected without the need for the submitter to type them in.) Please note this associates with a particular listing, unlike the XML submission option which adds listings from a feed into a specified category.

By default the data will be displayed in the listing details template, but you can put it anywhere. Use <!-- BEGIN FEEDS --> and <!-- END FEEDS --> to denote where the feed entry begins and ends, anywhere within the scope of a link. Then use {FEED + capitalized name of RSS field + } to display field data. For example:

<!-- BEGIN FEEDS -->
<a href="{FEEDLINK}">{FEEDTITLE}</a> by {FEEDAUTHOR} on {FEEDPUBDATE}:
<br>{FEEDDESCRIPTION}
<br>
<!-- END FEEDS -->


This is essentially what's in your listing details template already.

To control the number of feed items shown, insert the desired number between BEGIN and FEED: <!-- BEGIN 5 FEEDS -->.

The feeds are cached for 12 hours by default, you can change the cache timeout at Admin -> Settings -> Listings. In the event of a bottleneck each page load will only update 3 caches, the rest will be left for the next page in order to not drag out page load time too long.

To detect if the feed is empty, use {IMAGETOTALINFEED} in a conditional like <IF not {IMAGETOTALINFEED}>No items in this feed.</IF>

Advanced Tasks

To get the attribute values of a self-closing tag (as of 5.1.15), use {FEED + FIELDNAME + ATTRIBUTE NAME + }. For example, in podcast feeds there's often a line like this:
<enclosure url="http://..." type="audio/mpeg" length="1930012" />

To display the details of that referenced audio file, use this template code:
<a href="{FEEDENCLOSUREURL}">Download the {FEEDENCLOSURETYPE} file ({FEEDENCLOSURELENGTH} bytes)</a>


If you want to display the length in megabytes instead of bytes you can use some simple template PHP:

<a href="{FEEDENCLOSUREURL}">Download the {FEEDENCLOSURETYPE} file (<?php echo round(({FEEDENCLOSURELENGTH}/1048576), 2); ?> megabytes)</a>


Rating:


2/5 based on 1 vote. The median rating is 2.

Submitted: 11/23/06 (Edited 12/03/09)

Description: Displaying data from a feed related to a site.

Views: 1188 views. Averaging 1 views per day.
In the most recent 30 day period, there've been 7 views.

Previous Article | Next Article

Features Showcase Purchase Services Resources Support