I found the same code in a project that someone posted on umbraco. I have implemented the code but i get one error. Im not sure if you could look at it and help me out. Im lost at this point.
Error occured
Error in XSLT at line 73, char 11 71: <ul> 72: <xsl:for-each select="$feedContent//item"> 73: >>> <xsl:if test="position() > $recordsPerPage * number($pageNumber - 1) and position() <= number($recordsPerPage * number($pageNumber - 1) + $recordsPerPage )"> <<< 74: <li> 75:
<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>
Your variables are declared inside the main template (match="/") so they are not available outside of that template. If you move the variable declarations up just a little, I think it will work fine :)
thanks that fixed that one. One more for you. I get the following error
System.Xml.Xsl.XslLoadException: The variable or parameter 'numberOfRecords' is either not defined or it is out of scope.
Here is the line of code <xsl:if test="(($pageNumber) * $recordsPerPage) < ($numberOfRecords) ">
I don't see any where i can define the number of records. If I take out the $numberOfRecords it works and renders on the page. The only thing is the next button thows an Page not found - No umbraco document matches the url 'http://localhost/resources/current-sermons.aspx/2'
but there are a few other inconsistencies in the code you've got - the paging code is designed for multiple nodes underneath the current one - you need to change the for.loop template - where it is called, it is counting the number of subnodes - I think that should use the $numberOfRecords variable.
Finally the page links need changing - in the foor.loop template change:
Paging XSLT Item List
I currently have The Runway Rss Feedviewer pulling in an rss feed with about 50 items. I was wondering if there was a simple way to page the items.
Hi Eric,
Take a look at this: http://www.nibble.be/?p=11
/Simon
Yea i have tried his code but is seem very slopy and plus i get errors. Thank for the link
Simon,
I found the same code in a project that someone posted on umbraco. I have implemented the code but i get one error. Im not sure if you could look at it and help me out. Im lost at this point.
Error occured
Error in XSLT at line 73, char 11
71: <ul>
72: <xsl:for-each select="$feedContent//item">
73: >>> <xsl:if test="position() > $recordsPerPage * number($pageNumber - 1) and position() <= number($recordsPerPage * number($pageNumber - 1) + $recordsPerPage )"> <<<
74: <li>
75:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
]>
<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="excerptLength" select="1000" />
<xsl:variable name="feed" select="string('http://thesaltminechurch.podbean.com/feed/')"/>
<!-- cache for 30 minutes (1.800 seconds) -->
<xsl:variable name="cacheRate" select="number(1800)"/>
<xsl:template match="/">
<xsl:variable name="recordsPerPage" select="5"/>
<xsl:variable name="pageNumber">
<xsl:choose>
<xsl:when test="umbraco.library:RequestQueryString('page') <= 1 or string(umbraco.library:RequestQueryString('page')) = '' or string(umbraco.library:RequestQueryString('page')) = 'NaN'">1</xsl:when>
<xsl:otherwise>
<xsl:value-of select="umbraco.library:RequestQueryString('page')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- 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) > 0">
<ul>
<xsl:for-each select="$feedContent//item">
<xsl:if test="position() > $recordsPerPage * number($pageNumber - 1) and position() <= number($recordsPerPage * number($pageNumber - 1) + $recordsPerPage )">
<li>
<h2>
<xsl:value-of select="title" disable-output-escaping="yes"/>
</h2>
<strong>
<small>
<xsl:value-of select="umbraco.library:LongDate(pubDate)"/>
</small>
</strong>
<br/>
<br/>
<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>
<br/>
<a href=" {enclosure/@url} ">
<img style="vertical-align:middle;" src="/images/play.jpg" /> Listen Now
</a>
</li>
<br/>
<br/>
<br/>
<br/>
</xsl:if>
</xsl:for-each>
<!-- <li class="last"><xsl:text disable-output-escaping="yes">&</xsl:text>nbsp;</li> -->
</ul>
</xsl:if>
<xsl:if test="$pageNumber > 1">
<a href="{umbraco.library:NiceUrl($currentPage/@id)}/{$pageNumber - 1}">previous</a>
</xsl:if>
<xsl:call-template name="for.loop">
<xsl:with-param name="i">1</xsl:with-param>
<xsl:with-param name="page" select="$pageNumber"></xsl:with-param>
<xsl:with-param name="count" select="ceiling(count($currentPage/node) div $recordsPerPage)"></xsl:with-param>
</xsl:call-template>
<xsl:if test="(($pageNumber) * $recordsPerPage) < ($numberOfRecords)">
<a href="{umbraco.library:NiceUrl($currentPage/@id)}/{$pageNumber + 1}">next</a>
</xsl:if>
</xsl:template>
<xsl:template name="for.loop">
<xsl:param name="i"/>
<xsl:param name="count"/>
<xsl:param name="page"/>
<xsl:if test="$i <= $count">
<xsl:if test="$page != $i">
<a href="{umbraco.library:NiceUrl($currentPage/@id)}/{$i}" >
<xsl:value-of select="$i" />
</a>
</xsl:if>
<xsl:if test="$page = $i">
<xsl:value-of select="$i" />
</xsl:if>
</xsl:if>
<xsl:if test="$i <= $count">
<xsl:call-template name="for.loop">
<xsl:with-param name="i">
<xsl:value-of select="$i + 1"/>
</xsl:with-param>
<xsl:with-param name="count">
<xsl:value-of select="$count"/>
</xsl:with-param>
<xsl:with-param name="page">
<xsl:value-of select="$page"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Hi Simon
Your variables are declared inside the main template (match="/") so they are not available outside of that template. If you move the variable declarations up just a little, I think it will work fine :)
and then the rest of the xslt
Simon,
thanks that fixed that one. One more for you. I get the following error
System.Xml.Xsl.XslLoadException: The variable or parameter 'numberOfRecords' is either not defined or it is out of scope.
Here is the line of code <xsl:if test="(($pageNumber) * $recordsPerPage) < ($numberOfRecords) ">
I don't see any where i can define the number of records. If I take out the $numberOfRecords it works and renders on the page. The only thing is the next button thows an Page not found - No umbraco document matches the url 'http://localhost/resources/current-sermons.aspx/2'
You have any suggestion?
Hi Eric,
you need to define the variable numberOfRecords
but there are a few other inconsistencies in the code you've got - the paging code is designed for multiple nodes underneath the current one - you need to change the for.loop template - where it is called, it is counting the number of subnodes - I think that should use the $numberOfRecords variable.
Finally the page links need changing - in the foor.loop template change:
to
I think that will cover everything :)
/Josh
Josh,
Thanks for all you help
is working on a reply...