Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Eric Warren 48 posts 68 karma points
    Jul 19, 2010 @ 14:29
    Eric Warren
    0

    Need Runway Feed Viewer xslt code but not the whole runway project.

    I was wondering if there was a way to install just the feed viewer xslt rather than the whole project.  Or if there is a place where I can grab the code for the feed viewer.

  • Eric Warren 48 posts 68 karma points
    Jul 19, 2010 @ 14:55
    Eric Warren
    0

    Never Mind I Found The Code.  But here it is just in case someone else needs it.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
           
    version="1.0"
           
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
           
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
           
    xmlns:umbraco.library="urn:umbraco.library"
           
    exclude-result-prefixes="msxml umbraco.library">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:variable name="numberOfItems">
           
    <xsl:choose>
                   
    <xsl:when test="/macro/numberOfItems != ''">
                           
    <xsl:value-of select="/macro/numberOfItems"/>
                   
    </xsl:when>
                   
    <xsl:otherwise>10</xsl:otherwise>
           
    </xsl:choose>
    </xsl:variable>
    <xsl:variable name="excerptLength">
           
    <xsl:choose>
                   
    <xsl:when test="string(/macro/excerptLength) != ''">
                           
    <xsl:value-of select="/macro/excerptLength"/>
                   
    </xsl:when>
                   
    <xsl:otherwise>0</xsl:otherwise>
           
    </xsl:choose>
    </xsl:variable>

    <xsl:variable name="feed" select="/macro/feedUrl"/>
    <!-- cache for 30 minutes (1.800 seconds) -->
    <xsl:variable name="cacheRate" select="number(1800)"/>

    <xsl:template match="/">

    <!-- start writing XSLT -->
    <xsl:choose>
           
    <xsl:when test="$feed != ''">
                   
    <xsl:variable name="feedContent" select="umbraco.library:GetXmlDocumentByUrl($feed, number($cacheRate))"/>
                   
    <xsl:choose>
                           
    <xsl:when test="$feedContent != 'error'">
                                   
    <xsl:call-template name="renderFeed">
                                           
    <xsl:with-param name="feedContent" select="$feedContent"/>
                                   
    </xsl:call-template>
                           
    </xsl:when>
                           
    <xsl:otherwise>
                                   
    <p>
                                           
    <strong>Feed Viewer Macro Error: Error fetching feed</strong><br />
                                            The feed '
    <xsl:value-of select="$feed"/>' could not be loaded. Verify that the feed url exists and that you have an
                                            active internet connection
                                   
    </p>
                           
    </xsl:otherwise>
                   
    </xsl:choose>
           
    </xsl:when>
           
    <xsl:otherwise>
                   
    <p>
                           
    <strong>Feed Viewer Macro Error: No feed chosen</strong><br />
                            Please make sure to add a value in the "Feed Url" parameter
                   
    </p>
           
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    <xsl:template name="renderFeed">
    <xsl:param name="feedContent"/>
    <xsl:if test="count($feedContent//item) &gt; 0">
    <ul class="feedList">
           
    <xsl:for-each select="$feedContent//item">
                   
    <xsl:if test="position() &lt;= $numberOfItems">
                           
    <li>
                                   
    <small><xsl:value-of select="umbraco.library:LongDate(pubDate)"/></small>
                                   
    <h4>
                                           
    <a href="{link}">
                                           
    <xsl:value-of select="substring(title, 10)" disable-output-escaping="yes"/>
                                           
    </a>
                                   
    </h4>
                                   
    <xsl:choose>
                                           
    <xsl:when test="string($excerptLength) != '0'">
                                                   
    <p>
                                                           
    <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(description), number($excerptLength), '...')" disable-output-escaping="yes"/>
                                                   
    </p>
                                           
    </xsl:when>
                                           
    <xsl:otherwise>
                                                   
    <!-- <xsl:value-of select="description" disable-output-escaping="yes"/> -->
                                           
    </xsl:otherwise>
                                   
    </xsl:choose>
                                   
                           
    </li>
                   
    </xsl:if>
           
    </xsl:for-each>
    <li class="last"><xsl:text disable-output-escaping="yes">&amp;</xsl:text>nbsp;</li>
    </ul>
    </xsl:if>
    </xsl:template>

    </xsl:stylesheet>

  • David Tak 7 posts 27 karma points
    Jul 14, 2012 @ 14:49
    David Tak
    0

    Hi i need some help, and question

    instead of using parameters in xsl

    i would like to use document properties to select rss feed

    so i can change it easily threw the content section.

    I hope this is possible

     

    Greets

    David

  • Brendan Rice 538 posts 1102 karma points
    Jul 16, 2012 @ 00:17
    Brendan Rice
    0

    1. Select the node by node type or by nodeid

    http://our.umbraco.org/wiki/reference/umbracolibrary/getxmlnodebyid-(1)

    2. Get the property you want to use

    You can also pass parameters to a macro:

    http://our.umbraco.org/wiki/reference/templates/umbracomacro-element/macro-parameters

    It might be worth your while digging through the Wiki as there is a lot of useful info on there.

    Hope this helps.

  • David Tak 7 posts 27 karma points
    Jul 16, 2012 @ 18:59
    David Tak
    0

    not exactly what i mean i guess

    this is my xslt

    i changed number of items and feed url, so it would grab content out of document property, but it doesn't work.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library"
      exclude-result-prefixes="msxml umbraco.library">


    <xsl:output method="xml" omit-xml-declaration="yes"/>


        
    <xsl:param name="currentPage"/>

    <xsl:variable name="numberOfItems">
      <xsl:choose>
        <xsl:when test="data [@alias = 'numberOfItems']">
          <xsl:value-of select="data [@alias = 'numberOfItems']" />
        </xsl:when>
        <xsl:otherwise>10</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

        
    <xsl:variable name="feed" select="data [@alias = 'url']"/>
    <!-- cache for 30 minutes (1.800 seconds) -->
    <xsl:variable name="cacheRate" select="number(1800)"/>

    <xsl:template match="/">

    <!-- start writing XSLT -->
    <xsl:choose>
      <xsl:when test="$feed != ''">
        <xsl:variable name="feedContent" select="umbraco.library:GetXmlDocumentByUrl($feed)"/>
        <xsl:choose>
          <xsl:when test="$feedContent != 'error'">
            <xsl:call-template name="renderFeed">
              <xsl:with-param name="feedContent" select="$feedContent"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <p>
              <strong>Feed Viewer Macro Error: Error fetching feed</strong><br />
              The feed '<xsl:value-of select="$feed"/>' could not be loaded. Verify that the feed url exists and that you have an
              active internet connection
            </p>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <p>
          <strong>Feed Viewer Macro Error: No feed chosen</strong><br />
          Please make sure to add a value in the "Feed Url" parameter
        </p>
      </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    <xsl:template name="renderFeed">
    <xsl:param name="feedContent"/>
    <xsl:if test="count($feedContent//item) &gt; 0">
    <ul class="feedList">
      <xsl:for-each select="$feedContent//item">
        <xsl:if test="position() &lt;= $numberOfItems">
          <li>
            <a href="{link}"><xsl:value-of select="title"/></a><br></br>
            <small><xsl:value-of select="umbraco.library:LongDate(pubDate)"/></small>
          </li>
        </xsl:if>
      </xsl:for-each>
    </ul>
    </xsl:if>
    </xsl:template>

    </xsl:stylesheet>

Please Sign in or register to post replies

Write your reply to:

Draft