Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsNews FeedsNews FeedsNews Feed (RSS) Free Video Tutorial & XSL Transformation tutorial with filesNews Feed (RSS) Free Video Tutorial & XSL Transformation tutorial with files
Previous
 
Next
New Post
11/1/2005 11:02 AM
 
Hello,

As promised, I have created a free video tutorial for you.

DotNetNuke® News Feed (RSS) Module - video tutorial
http://www.dnncreative.com/Tutorials/DNNTutorialsforCoreModules/DotNetNukeNewsFeedRSSModule/tabid/169/Default.aspx

Setting up the RSS News Feed XSL Stylesheet - with 6 examples to download
http://www.dnncreative.com/Tutorials/DNNTutorialsforCoreModules/RSSNewsFeedXSLStylesheet/tabid/162/Default.aspx


I've just released issue 3 of DNN Creative Magazine which is completely dedicated to RSS, so you may all find some useful information. There are 8 free articles related to RSS and plenty of other information.

Issue 3 - RSS and DotNetNuke
http://www.dnncreative.com/Home/2005Issues/Issueno3/tabid/188/Default.aspx

Hope this is useful, thanks, Lee
http://www.dnncreative.com

Lee Sykes - DNN Creative Magazine - 600+ Video Tutorials, Articles, Interviews - July Issue 58 out now!
DNN Creative Magazine for DotNetNuke

Twitter: www.twitter.com/DNNCreative

Lee Sykes's Facebook Profile
 
New Post
5/20/2008 3:40 PM
 

Hi There.

This is such a stab in the dark, but I really have come royally unstuck on this one - I have spent over 6 hours going over both DNNCreative's XSL Tutorial and your (and IWonder's) numerous posts on DotNetNuke Forums.

Could really do with anyone's help.

I have set up an RSS News module on my site, linked to http://www.dispatch.co.za/rss/Daily%20Dispatch_News.xml

This module sits in a 200px Wide Container.  I've tried numerous times, but failed miserably (I'm new to XML and XSL to style how this feed displays.  I've obviously used all the templates provided on DNNCreative, but am battling to get it right with this particular feed.

I'd like to display the feed as follows:

  • Only display the first 5 entries
  • Display Title
  • Do not display the image
  • Display concatonated description (say 120 characters)
  • Display Publish Date


It seems as though the original feed has an image as part of the description, and thus the image always displays, regardless of how I set it.
I've seen a number of posts with similar problems, but none that I could decipher successfully to sort out my problem.  Again, any help - or at least a point in the right post's direction.

Regards Jon


Shebang Websites - A product of Mogridge Design
Hey, we're partnered with UntangleMyWeb.com

 
New Post
5/20/2008 11:14 PM
 

Jon,

Welcome to the wonderful world of RSS, XML, and XSL!!!  I must say at the outset, you've chosen a very difficult and challenging newsfeed to decipher and use.  It is a challenge to go through.  As you know from reading my posts, the first step is to examine the newsfeed source, view the code, and work through it.  I really can't go into all of the details in this post, but will promise to take this challenge up on my seldom used blog, where I have more space to use for such madness.

The keys to doing what you want will take some programming effort and skill, so you really need to bone up on all of the components, RSS, XML, and RSS to customize the feed in the manner you want.  There are no short cuts, like you didn't know, right?

Anyway, for starters, take the bits that are easiest and work from there.  For example, there are many posts dealing with how to limit the number of entries.  Take the code for that and store it somewhere for later use.  Now, I'm really assumming you want to learn how to do this stuff, and not just get a freebie xsl. 

So, first step - examine the feed to see what type of feed you are messing with.  Here's a start - the following code contains info that identifies the type of RSS feed being used, and the namespaces used in the feed for the various attributes it contains.

<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0"

xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/" >

Now, the feed is an RSS v.20 - but that can be misleading, so we look at the namespaces contained in it, and find a reference to an RDF namespace.  Why is that important?  Well, because it's a key to getting the description info you want without all of the muck.    I take the http reference and visit the site to find out just what is being used.  In this example, it's pretty easy - the attribute content is being defined.

Now, this is a start and I'll give you more in the morning, as I'm losing power to my laptop and on the bus at night, pretty scarry stuff, hauling a laptop and taking a bus, but things are what they are today.

Promise to follow up, hope this gives you a bit of insight and help.

Cheers

 
New Post
5/21/2008 2:53 PM
 

Allright, here is one solution that takes care of your needs.  The keys to limiting the number of items displayed  is simple coding.  Displaying only the text of the descriptions is a little trickier, and relies heavily on how a feed is delivered by the new source provider, which is always subject to change.  Here in this example, a namespace is used to allow use of the attribute 'content:encoded' which contains mostly text and html, but that may not always be the case. 

At any rate here's the xsl I used on my text dnn v04.05.05 site.  I placed the rss module in the content portion of a page.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   xmlns:dc="http://purl.org/dc/elements/1.1/">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<!-- RSSv2.0 XSL stylesheet -->
<!-- Displays only 5 items and only 120 char of content:encoded text -->
<!-- 2008/05/21 By Request -->
<!-- Author: Phil 'iwonder' Guerra -->
<!-- Use with Author Attribution Please -->
<!-- ================================== -->

<xsl:template match="/">
<style media="all" lang="en" type="text/css">
.rssChannelTitle
{
 font-family:  Tahoma;
   font-size:  13pt;
 font-weight:  bold;
  text-align:  Left;
}
.rssChannelDescription
{
 font-family: Times;
   font-size: 11pt;
 font-weight: Bold;
  text-align: Left;
}
.rssItemTitle
{
 font-family:  Verdana;
   font-size:  10pt;
   font-weight: BOLD;
 font-color: #00000;
}
.rssItemDescription
{
 font-family:  Verdana;
   font-size:  10pt;
   font-weight:  Normal;
 font-color: red;
}
.rssItemPubDate
{
 font-family:  Times;
   font-size:  8pt;
   font-weight:  Normal;
 font-color: #000000;
}
</style>

<div>
  <xsl:apply-templates select="rss/channel"/>
  </div>
</xsl:template>
<xsl:template match="rss/channel">
<xsl:variable name="link" select="link"/>
  <xsl:variable name="description" select="description"/>
  <xsl:variable name="image" select="image/url"/>
  <xsl:variable name="idesc" select="image/description"/>
  <xsl:variable name="ilink" select="image/link"/>
  <xsl:variable name="iwide" select="image/width"/>
  <xsl:variable name="ihigh" select="image/height"/>

<div class="rssChannelTitle">
 <xsl:if test="$image">
    <a href="{$ilink}" title="{$idesc}"><xsl:value-of select="ilink" /></a>
    <img src="{$image}" height="{$ihigh}" width="{$iwide}" style="float: left; margin: 2px; border: 0px;"/>
 </xsl:if> 
 <a href="{$link}"><xsl:value-of select="title" /></a><br/>
 </div>
<div class="rssChannelDescription">
 <xsl:value-of select="substring(description,1,120)" disable-output-escaping="no"/><br/>
</div>
<div class="rssChannelsubHead">
 <xsl:value-of select="webMaster"/><br/>
 <xsl:value-of select="copyright"/><br/>
 <xsl:value-of select="lastBuildDate"/>
 <hr/>
</div>

  <xsl:apply-templates select="item"/>
</xsl:template>
<xsl:template match="item">
<xsl:if test="position() &lt; 6"> <!-- limit the display to 5 items -->
  <xsl:variable name="item_link" select="link"/>
  <div class="rssItemTitle">
    <a href="{$item_link}" ><xsl:value-of select="title" disable-output-escaping="yes"/></a>
</div>
<div class="rssItemPubDate">
 (<xsl:value-of select="pubDate"/>)
</div>
<div class="rssItemDescription">
 <xsl:value-of select="substring(content:encoded,4,120)" disable-output-escaping="yes"/>...<br/>
</div> <hr/>
</xsl:if> <!-- end of If statement block for limiting number of items -->
 </xsl:template>

</xsl:stylesheet>

And the output looks like this:

All the top News stories



(Wed, 21 May 2008 06:40:00 GMT)
TWO reports by the World Health Organisation and national Health Department have given irrefutable proof that the public...

(Wed, 21 May 2008 06:40:00 GMT)
EAST Londoners have vowed that they will not stand by and allow xenophobic attacks to spill over into their city . The p...

(Wed, 21 May 2008 06:40:00 GMT)
AT LEAST five employees of Mercedes- Benz South Africa are on suspension for two separate racial incidents. Union offici...

(Wed, 21 May 2008 06:40:00 GMT)
A ONE-TIME bank robber has come to the rescue of two teenage East London girls by paying for them to go overseas to repr...

(Wed, 21 May 2008 06:40:00 GMT)
THE advance on Moscow is all but complete, and for Chelsea and Manchester United, that means a chance to win the biggest...

In the xsl you'll see lots of ideas of things you can modify to suit, including CSS styles.  Give it a go  and let me know how it works for you.

 

Cheers! ;-)

 
New Post
5/21/2008 4:05 PM
 

And yet another partial example that cleans up the item display, taking the first sentance of the content:encoded attribute. See the highlighted code for the way this is done.  Create an xsl variable, then select it for display.

Replace the item template with this one...

<xsl:template match="item">
<xsl:if test="position() &lt; 6"> <!-- limit the display to 5 items -->
  <xsl:variable name="item_link" select="link"/>
  <xsl:variable name="mycontent" select="substring(content:encoded,4)"/>
  <div class="rssItemTitle">
    <a href="{$item_link}" ><xsl:value-of select="title" disable-output-escaping="yes"/></a>
</div>
<div class="rssItemPubDate">
 (<xsl:value-of select="pubDate"/>)
</div>
<div class="rssItemDescription">
<!-- <xsl:value-of select="substring(content:encoded,4,120)" disable-output-escaping="yes"/>...<br/> -->
 <xsl:value-of select="substring-before($mycontent,'.')" disable-output-escaping="yes"/>.<br/>
</div> <hr/>
</xsl:if> <!-- end of If statement block for limiting number of items -->
 </xsl:template>

Outputs like this:

All the top News stories



(Wed, 21 May 2008 06:40:00 GMT)
TWO reports by the World Health Organisation and national Health Department have given irrefutable proof that the public healthcare system and sanitation services had collapsed in Ukhahlamba District, where scores of babies died from diarrhoea.

(Wed, 21 May 2008 06:40:00 GMT)
EAST Londoners have vowed that they will not stand by and allow xenophobic attacks to spill over into their city .

(Wed, 21 May 2008 06:40:00 GMT)
AT LEAST five employees of Mercedes- Benz South Africa are on suspension for two separate racial incidents.

(Wed, 21 May 2008 06:40:00 GMT)
A ONE-TIME bank robber has come to the rescue of two teenage East London girls by paying for them to go overseas to represent Africa at an international schools’ competition in the US.

(Wed, 21 May 2008 06:40:00 GMT)
THE advance on Moscow is all but complete, and for Chelsea and Manchester United, that means a chance to win the biggest prize in European club football.

You get a much more palatable description, breaking at the end of the first sentance, rather than somewhere in the middle.  The caution is this, though - the procedure is dependent on the news source actually providing the first sentance, ending with a period.  Of course, you may have to tweak it more, but that's why I like being able to customize things in the first place.

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsNews FeedsNews FeedsNews Feed (RSS) Free Video Tutorial & XSL Transformation tutorial with filesNews Feed (RSS) Free Video Tutorial & XSL Transformation tutorial with files


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out