Skip navigation
Currently Being Moderated

xslt conditional to limit words in a feed

Feb 10, 2009 1:33 PM

I'm trying to use XSLT in DW to do a news feed and can't figure out how to limit the number of words in the description. I'm using David Power's book as an example. I'm showing the Titles as links and the Descriptions fine and can limit the number of objects to display. But I can't figure out how to limit the number of words in the Descriptions. I want to display the feed in a sidebar and just show the first couple of lines from the description as a teaser.

Any suggestions appreciated.
 
Replies
  • Currently Being Moderated
    Feb 10, 2009 3:52 PM   in reply to Bob Timms
    Bob Timms wrote:
    > I'm trying to use XSLT in DW to do a news feed and can't figure out how to
    > limit the number of words in the description.

    My knowledge of XSLT is pretty basic, so I can't suggest a way to select
    a specific number of words. However, it's very easy to select the first
    sentence. The following example cuts off the contents of a <description>
    tag at the first period followed by a space, and adds an ellipsis:

    <xsl:value-of select="substring-before(description, '. ')"/>
    <xsl:text>...</xsl:text>

    --
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS4",
    "PHP Solutions" & "PHP Object-Oriented Solutions"
    http://foundationphp.com/
     
    |
    Mark as:
  • Currently Being Moderated
    Feb 11, 2009 2:12 AM   in reply to Bob Timms
    Bob Timms wrote:
    > Grabbed your book for PHP/MySQL -
    > I can't believe I've used DW since DW MX and never investigated server
    > behaviors until your book. Learned a lot and my workflow has become a ton more
    > effecient.

    Glad to have been of help. If you've got a spare moment, why not spread
    the word by posting a review on Amazon? ;-)

    --
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS4",
    "PHP Solutions" & "PHP Object-Oriented Solutions"
    http://foundationphp.com/
     
    |
    Mark as:
  • Currently Being Moderated
    Feb 12, 2009 5:58 AM   in reply to Newsgroup_User
    Bob Timms wrote:
    > I'll be happy to as soon as I get a break. I'm covered up right now - but I'm not complaining.

    No pressure. If you've got time, great. If not, no problem.

    --
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS4",
    "PHP Solutions" & "PHP Object-Oriented Solutions"
    http://foundationphp.com/
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points