Copied to clipboard

Flag this post as spam?

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


  • curlybub 133 posts 107 karma points
    Aug 10, 2009 @ 09:31
    curlybub
    0

    XSLT paging with content preview

    Hi,

    I have an umrbaco site that is structured like this (left side of the picture) http://i59.photobucket.com/albums/g294/Curlybub26/paging-with-content-preview.jpg There would be serveral news that will be displayed maybe around 30 items. I want to achieve the output on the right http://i59.photobucket.com/albums/g294/Curlybub26/paging-with-content-preview.jpg wherein there is a paging, title and a line from the content is listed. I found an XSLT like this before already in the forums. However I cannot see it anymore. Does anyone here have a link to that XSLT?

    Thank you.

    Regards,

    Harry

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Aug 10, 2009 @ 09:38
    Dirk De Grave
    0

    Hi Harry,

     

    Don't know of an example in the forums, but here's an excellent example.

     

    Cheers,

    /Dirk

  • curlybub 133 posts 107 karma points
    Aug 10, 2009 @ 09:52
    curlybub
    0

    Hi Dirk,

    Im trying to make the 2 examples at that website to work for me. I think it has problems with the `` and ` trying to replace those and still getting some errors. I cannot make it to work.

    Thank you.

    Regards,

    Harry

  • curlybub 133 posts 107 karma points
    Aug 10, 2009 @ 09:54
    curlybub
    0

    Here is the code that Im currently fixing from the site:

    <?

     

    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:template match="/">

    <

     

    xsl:variable name="recordsPerPage" select="1"/>

    <

     

    xsl:variable name="pageNumber" >

    <

     

    xsl:choose>

    <

     

    xsl:when test="umbraco.library:RequestQueryString('page') &lt;= 0 or string(umbraco.library:RequestQueryString('page')) = " or string(umbraco.library:RequestQueryString('page')) = 'NaN'">0</xsl:when>

    <

     

    xsl:otherwise>

    <

     

    xsl:value-of select="umbraco.library:RequestQueryString('page')"/>

    </

     

    xsl:otherwise>

    </

     

    xsl:choose>

    </

     

    xsl:variable> &nbsp;

     

    <

     

    xsl:variable name="numberOfRecords" select="count($currentPage/node)"/>

    <

     

    ul>

    <

     

    xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">

    <

     

    xsl:if test="position() &gt; $recordsPerPage * number($pageNumber) andposition() &lt;= number($recordsPerPage * number($pageNumber) +$recordsPerPage )">

    <

     

    li>

    <

     

    a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>

    </

     

    li>

    </

     

    xsl:if>

    </

     

    xsl:for-each>

    </

     

    ul>

     

    <

     

    xsl:if test="$pageNumber &gt; 0">

    <

     

    a href="?page{$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 +1"></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 +1 ) * $recordsPerPage) &lt; ($numberOfRecords)">

    <

     

    a href="?page={$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 &lt;= $count">

    <

     

    xsl:if test="$page != $i">

    <

     

    a href="{umbraco.library:NiceUrl($currentPage/@id)}?page={$i - 1}" ><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 &lt;= $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>

    Im having an error on this area <xsl:when test="umbraco.library:RequestQueryString('page') &lt;= 0 or string(umbraco.library:RequestQueryString('page')) = " or string(umbraco.library:RequestQueryString('page')) = 'NaN'">0</xsl:when>

    :D

Please Sign in or register to post replies

Write your reply to:

Draft