I have modified the xslt file for navigation a bit, so the paging is more appropriate and starts with 1 instead of 0.. so ?page=1, ?page=2 .. etc...
I have done this before on this site: http://oldengaard.dk/da/nyheder.aspx in another navigation, but the paging technique is the same ( I mean I previously was modifying the code in relation to this file http://our.umbraco.org/projects/developer-tools/paging-xslt )... however I have a problem with the first page item ... when I change umbraco.library:RequestQueryString('page') <= 0 to a value of zero the first item is is highlighted (have the currentpageitem class.. but not when I don't have the ?page=X in the url like this http://sub.ak-security.dk/da/aktuelt/nyheder.aspx
<!-- WHAT IS THIS FILE? A list of news nodes written as an ul li list. Will have an array of classes to help styling. Settings include: - newsListPage (Will show news from this specific page) - newsHeadingNumber (Can be any number which will be appended to a h. Default is a h2.) - staticNumberOfNews (Will allways show only this number of news. No paging will be applied) - newsPerPage (Paging will use this to show a specific number of news per page) -->
Yeah, I have been meaning to fix that for some time, and did it on my last project. Your post have been a good excuse to get it implemented in the Starter Kit and it will be released next time. Until then here's the links to the new files you need for properly paging of the news list.
The first one is the newslist which you can owerwrite. The second one is the new paging, which I have moved to it's own xslt for reuse. It can page anything.
Just throw them both in the xslt folder and your'e good to go.
Thanks for the files.. just what I was looking for.. It works perfect.. and nice the paging has it's own file, so the code is reused when having other files using the paging too..
Yes, I've noticed that you use items instead of news some places, but it doesn't matter.. of course the classes must be the same as the ones in css, but the names of the varibles could be items as well...
I see you have changed one of the first lines from: <xsl:variable name="allItems" select="umbraco.library:GetXmlNodeById(/macro/newsListPage)/Items | $currentPage/News" />
to: <xsl:variable name="allItems" select="umbraco.library:GetXmlNodeById(/macro/newsListPage)/News | $currentPage/News" />
Furthermore I added a couple of classes to the current page and page item: <xsl:choose> <xsl:when test="number($pageNumber) = number($i)"> <span class="currentpageitem"> <xsl:value-of select="$i" /> span> </xsl:when> <xsl:otherwise> <a class="pageitem" href="?page={$i}{$extraParams}"> <xsl:value-of select="$i" /> </a> </xsl:otherwise> </xsl:choose>
But without the changes you just made it seem to work just fine here: http://sub.ak-security.dk/da/aktuelt/nyheder.aspx , but only on currentPage.. with the correction I first wrote, it also works on frontpage..
Starterkit xslt navigation
Hi..
I have modified the xslt file for navigation a bit, so the paging is more appropriate and starts with 1 instead of 0.. so ?page=1, ?page=2 .. etc...
I have done this before on this site: http://oldengaard.dk/da/nyheder.aspx in another navigation, but the paging technique is the same ( I mean I previously was modifying the code in relation to this file http://our.umbraco.org/projects/developer-tools/paging-xslt )... however I have a problem with the first page item ... when I change umbraco.library:RequestQueryString('page') <= 0 to a value of zero the first item is is highlighted (have the currentpageitem class.. but not when I don't have the ?page=X in the url like this http://sub.ak-security.dk/da/aktuelt/nyheder.aspx
My full xslt look like this:
best regards..
Bjarne
Just ignore the first xslt code, as it was missing some of the code.. and somehow I couldn't just change it..
Bjarne
Hi Bjarne,
Yeah, I have been meaning to fix that for some time, and did it on my last project. Your post have been a good excuse to get it implemented in the Starter Kit and it will be released next time. Until then here's the links to the new files you need for properly paging of the news list.
http://www.teacommerce.dk/blogMedia/general_newsList.xslt
http://www.teacommerce.dk/blogMedia/utils_paging.xslt
The first one is the newslist which you can owerwrite. The second one is the new paging, which I have moved to it's own xslt for reuse. It can page anything.
Just throw them both in the xslt folder and your'e good to go.
/Rune
Hi Rune
Thanks for the files.. just what I was looking for..
It works perfect.. and nice the paging has it's own file, so the code is reused when having other files using the paging too..
Bjarne
Sorry Bjarne, I made a greedy replace in the newslist xslt. I have corrected the error and you can download a new one from the link above.
Some classes and xml property names where all wrong.
/Rune
Hi Rune..
Yes, I've noticed that you use items instead of news some places, but it doesn't matter.. of course the classes must be the same as the ones in css, but the names of the varibles could be items as well...
I see you have changed one of the first lines from:
<xsl:variable name="allItems" select="umbraco.library:GetXmlNodeById(/macro/newsListPage)/Items | $currentPage/News" />
to:
<xsl:variable name="allItems" select="umbraco.library:GetXmlNodeById(/macro/newsListPage)/News | $currentPage/News" />
Furthermore I added a couple of classes to the current page and page item:
<xsl:choose>
<xsl:when test="number($pageNumber) = number($i)">
<span class="currentpageitem">
<xsl:value-of select="$i" />
span>
</xsl:when>
<xsl:otherwise>
<a class="pageitem" href="?page={$i}{$extraParams}">
<xsl:value-of select="$i" />
</a>
</xsl:otherwise>
</xsl:choose>
But without the changes you just made it seem to work just fine here: http://sub.ak-security.dk/da/aktuelt/nyheder.aspx , but only on currentPage.. with the correction I first wrote, it also works on frontpage..
Bjarne
is working on a reply...