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 FeedsAdding Characters?Adding Characters?
Previous
 
Next
New Post
8/6/2008 5:11 PM
 

I am working on a newsfeed that has a max number of characters using this code

 

<xsl:template match="rss">
  <!-- Do not show channel image -->
  <xsl:for-each select="channel/item">
   <xsl:if test="position() &lt; 7">
       <div align="left"><font style="font-family:Verdana" size="1" color="#666666">
       <img src="http://65.61.47.133/Portals/0/images/bulletimage-regular.jpg" />
       <a href="{link}" target="_main">
<xsl:value-of select="substring(title,7,26)"/>
<xsl:if test="string-length(title)&gt;26">
       <xsl:text>...</xsl:text>
</xsl:if>
</a>
       </font><br />
          <br />
       </div>
   </xsl:if>
  </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

But as you see I have to start 7 characters in and end on 26 to work correctly

substring(title,7,26)

But for some reason some could go to like 35 before jumping to the next line - any idea what is going on here, someone please explain. I really apprieciate the help.

Thanks,

Randy

 

 
New Post
8/7/2008 12:56 AM
 

First, supply the newsfeed source you are using. 

Second, have you actually taken a look at the feed source file?  It could be that the issue is due to other formatting characters in the source itself.  They get counted too.

 
New Post
8/8/2008 10:30 AM
 

Thanks wonder, here is the link
http://www.myalleghenyeast.com/news/tabid/297/moduleid/814/RSS.aspx
I am not sure why but it adds a "-" before.

Thanks,

Randy

 

 
New Post
8/8/2008 11:58 AM
 

Ok, always, always, always inpect the source newsfeed if you want to understand what's happening.  I simply open the feed using IE, it's the browser loaded on my windows workstation, you can use whatever you want, and choose to View Source.  This allows me to view the raw rss/xml being feed by the news source.  You won't have much control over what they decide to supply, and any customized xsl will not doubt have to be revisited to account for any formatting changes they make - and trust me - they will change thier format.  My advice is to keep any customization as simple as possible.  While they may supply a lot of data in custom tags, including images and video, my experience with all news source providers is they will change formats every couple of months, just to keep folks from using their feeds w/o following any news source attribution, or just to enhance the look and feel of it themselves.

That being said, here's what I see....

First, it's an RSS v2.0, simple implementation w/o other namespaces, so far so good, and that's why you prolly chose to use a customized xsl.  DNN defaults to RSS v0.91 rss support.

<?xml version="1.0"?>
<rss version="2.0">
 <channel>
  <title>AEC</title>
  <link>http://www.myalleghenyeast.com</link>
  <description>AEC</description>
  <language>en-US</language>
  <copyright>Copyright 2007 by My Allegheny East Conference</copyright>
  <webMaster>support@creativeness.com</webMaster>

Now, the issues you see are related to how the news provider is giving you the data within the RSS elements.  Take a look at these to Item elements...

  <item>
   <title>     - Official Release about Elder Cheatham</title>
   <description>   This is the official information regarding the health of Allegheny East Conference President, Cha...</description>
   <link>http://www.myalleghenyeast.com/news/tabid/297/Default.aspx</link>
   <pubDate>Fri, 25 Jul 2008 04:00:00 GMT</pubDate>
   <guid>http://www.myalleghenyeast.com/news/tabid/297/Default.aspx?ItemId=55</guid>
  </item>
  <item>
   <title>     - Camp Meeting Schedules and Special Programs!</title>
   <description> 2008 Camp Meeting is under full swing with ten days of uplifting programs for the entire family.  T...</description>
   <link>http://www.myalleghenyeast.com/news/tabid/297/Default.aspx</link>
   <pubDate>Fri, 27 Jun 2008 04:00:00 GMT</pubDate>
   <guid>http://www.myalleghenyeast.com/news/tabid/297/Default.aspx?ItemId=51</guid>
  </item>

Note the spaces and dashes in the TITLE element and the spaces before the text in the DESCRIPTION element.

Both of these elements illustrate how some news providers don't really understand the real beauty of RSS as a tool to provide standardized data.  Some will include HTML to 'help' format their feed for you, while others try to format it within the element itself in this type of haphazard way.  I am a big fan of using CSS to do formatting, and provide RSS with text content only.  Seems to work better for all, when done that way, but that's my pref, but if I could I would disallow any other type of usage.

Ok, now how to deal with these issues...

Fortunately, XSL includes a number built-in functions to manipulate text, and that's would I would recommend boning up on. 

  • starts-with(main_string, prefix_string)

  • contains(containing_string, contained_string)

  • substring(string, offset, length)

  • substring-before(string, marker-string)

  • substring-after(string, marker-string)

  • string-length(string)

  • normalize(string)

  • translate(string, replaced_text, replacement_text)

  • concat(string1, string2, ...)

I don't have time to give you specific examples, but plenty of my earlier posts offer examples, and just google on XSL string functions to get many more examples.  Since your doing xsl, it's pretty much all works, with the exception of using some include and programming calls that could cause security issues.

Hope that gets you enough to get around these little annoyances.

 
New Post
8/8/2008 12:01 PM
 

Thanks wonder I really apprieciate the help - I will have to plug this in a little later - I am busy with some other things right now but I wanted to say thanks.

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsNews FeedsNews FeedsAdding Characters?Adding Characters?


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