Latest Register Log In

+ Advanced Search

Associating an RSS Feed With a Listing

Associating an RSS Feed With a Listing
By
11/23/06 (Edited 03/11/14)

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

In your listings switches at Admin -> Settings -> 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: associated feeds properly defined in the html are automatically detected without the need for the submitter to type them in, so just the main website url will often work. 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 in WSN 8 and older -- or at Admin -> Listings -> Listing Fields -> RSS Feed -> custom display html in WSN 9 and later.

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 -> Listings -> Listing Settings. 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 {LINKTOTALINFEED} in a conditional like <IF not {LINKTOTALINFEED}>No items in this feed.</IF>

Advanced Tasks

To get the attribute values of a self-closing tag, 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>




Description Displaying data from a feed related to a site.
Rating
Views 1548 views. Averaging 0 views per day.