Copied to clipboard

Flag this post as spam?

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


  • Robin Hansen 117 posts 248 karma points
    Jan 13, 2012 @ 15:32
    Robin Hansen
    0

    Pagination with dynamic items per page

    I use the this pagination script with great success... however I would like to give the user the abillity to choose between the amount of items shown.

    This codesnippet displays 25 items on the page:
      <xsl:param name="currentPage"/>
      <xsl:variable name="result" select="SolrSearch:Search('Aalborg')"/>
      <xsl:variable name="numberOfItems" select="count($result/descendant::Advertiser)"/>
      <xsl:variable name="itemsPerPage" select="25"/>
      <xsl:variable name="pageNumber">
        <xsl:choose>
          <xsl:when test="umbraco.library:RequestQueryString('side') = ''">
            <xsl:value-of select="1"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="umbraco.library:RequestQueryString('side')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>

    Instead of having a static amount of items is there a way to choose between several choices by using a DropDownList?:
    <select name="chooseItemsAmount" id="chooseItemsAmount">
                <option value="25">25</option>
                <option value="50">50</option>
                <option value="100">100</option>
                <option value="200">200</option>
    </select>

    All my attempt to to use the value of the DropDown inside the itemsPerPage variable seems to fail:
    <xsl:variable name="itemsPerPage" select="$chooseItemsAmount"/>

    Any one solved this...?

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Jan 13, 2012 @ 17:02
    Jan Skovgaard
    0

    Hi Robin

    What does your $chooseItemsAmount variable look like?

    /Jan

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Jan 13, 2012 @ 17:03
    Chriztian Steinmeier
    1

    Hi Robin,

    You can pass the value into the XSLT in the querystring just as you do with the page number etc., just set the variable like this:

    <!-- Grab from QueryString -->
    <xsl:variable name="reqPerPage" select="umbraco.library:RequestQueryString('chooseItemsAmount')" />
    <xsl:variable name="itemsPerPage">
        <xsl:choose>
            <xsl:when test="$reqPerPage"><xsl:value-of select="$reqPerPage" /></xsl:when>
            <xsl:otherwise>25</xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    

    /Chriztian

     

  • Robin Hansen 117 posts 248 karma points
    Feb 04, 2012 @ 11:56
    Robin Hansen
    0

    Hi Chriztian,

    Sorry for my late reply - your solution with the qurystring was what I needed - I intented NOT to use qurystrings prior to this thread but realized that it was inevitable... :-)

     

    \Robin

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies