Like me on Facebook Follow me on Twitter Register or    (Why?)
You are here Articles

All modules are now open sourced, please see the announcement here

 

Articles

08

First a little background

A new feature recently released as part of Aggregator 5.5 is the ability to use an RSS feed to dynamically build tabs. To set this up, all you have to do is go into the Aggregator settings screen and enter the url that points to an RSS feed in the RSS Url field. If you click update and go back to your page you should see the RSS feed displayed, one tab for each RSS item. This is the default view used for all RSS items if the skin you are using doesn't already have an RSSContent.html file defined for the skin. As of the time of this writing, there is only one skin in the release package that does have a RSSContent.html file, called Simple - RSS.

Building the template

For the purposes of demonstrating the building of the template, we're going to just add the RSSContent.html template to an existing skin. In production you'll want to add the RSSContent.html template to you own custom skin. The reason you'll want to do this is that when upgrading, the skins shipped with Aggregator can and may be overwritten with new templates. Please see this article to learn how to make a copy of an existing skin for your own use.

Ok, so lets pick an existing skin to work with. For this I'm going to suggest using the Simple - Left skin located in the folder /skins/Simple/Left. Go to this folder and create a new file named RSSContent.html.

RSS Tokens

Aggregator exclusively uses tokens within template bodies to determine what to place where. In the RSSContent.html file the case is no different, except that here we are using tokens specific to RSS feeds. The tokens available for RSS content match the most common fields of an RSS field, namely [RSSTITLE], [RSSAUTHOR], [RSSDESCRIPTION], [RSSLINK] and [RSSPUBDATE]. There is an exhaustive list of replaceable tokens located on the wiki.

Editing RSSContent.html

Ok, open the RSSContent.html file you created in the prior step in your favourite text or html editor. The only function of this template is to tell Aggregator how we want each RSS item to be displayed in the tab page when we are displaying an RSS item. For instance, if our RSS feed has 3 items in it, this template will be used 3 times (once for each rss item) and the data from the RSS item will be inserted into this template and then fed out to the page. Let's just add the following to the template for now and then save it and see what we have.

<h3>This is my RSS item</h3>
[RSSDESCRIPTION]

Now save the template and refresh your browser to see what the page shows. For each item in the feed, you should see the html we entered for the template, but where we put the [RSSDESCRIPTION] token, you should now see the description from your rss item. If you don't see a change, make sure you have your rss feed configured properly within Aggregator, and make sure you have selected the proper skin, Simple/Left in this case, unless you chose to change a different skin.

Ok, let's add some more things to the template. Open up the RSSContent.html file and change it to this:

<b>[RSSTITLE]</b><br />
[RSSDESCRIPTION]<br />
<a href="[RSSLINK]">... read more</a>

Save the template again, and refresh your browser and you should see changes. In this example you'll see the title of the rss item in bold, then the description and then a ... read more link which points to the full rss article.

Templates are an easy way to customize the look and feel of the data presented by the Aggregator. In fact, most of the html generated for each tab, tab page, and tabstrip is governed by the template files within the skin folder. The best way to learn about these powerful features is to create your own custom skin as a copy of an existing one, and then make incremental changes to get the look you want.

 

Post Rating

Comments

There are currently no comments, be the first to post one!

Post Comment

Only registered users may post comments.
Privacy StatementTerms Of UseCopyright (c) 2004-2015 DNNStuff
Page generated in 0.3125 seconds!