Copied to clipboard

Flag this post as spam?

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


  • trfletch 598 posts 604 karma points
    Apr 29, 2010 @ 16:38
    trfletch
    0

    Putting querystring in link on page

    Hi,

    I need to have a link on a page that contains the current querystring of the page (well two query strings to be exact), how do I do this in XSLT? Basically I want my link on the page to go to "/atestpage.aspx/?querystring1=querystring1value&querystring2=querystring2value&page=pagenumber. I currently have the following

     <a href="{umbraco.library:NiceUrl($currentPage/@id)}/(umbraco.library:Request('location'))?page={$pageNumber + 1}">next</a>

    but this just outputs /atestpage.aspx/?location=(umbraco.library:Request('location'))&page=2

    How can I make this link get the querystring value? Just in case you was wondering it is for a search results page that I want to add paging to, I therefore need the "next" link to go to the next page but keep the querystring values that were put in the form.

  • Chris Dunn 210 posts 401 karma points
    Apr 29, 2010 @ 16:51
    Chris Dunn
    0

    If your paging do you need to pass the page 'location' or just use the current page in which case you can just use the @id.

    Here is a great blog post about paging in xslt that might help.

    http://www.nibble.be/?p=11

    -Chris

  • bob baty-barr 1180 posts 1294 karma points MVP
    Apr 29, 2010 @ 16:54
    bob baty-barr
    2

    it looks as if a concat statement would work best here...

    i would set some variables first... just to keep things in order in  my mind...

    <xsl:variable name="thePage" select="umbraco.library:NiceUrl($currentPage/@id)"/>
    <xsl:variable name="theLoc" select="umbraco.library:Request('location')"/>

    Since you already have a variable for pageNumber, i think we are good there...

    then we can make a final variable to tie them all together like this...

    <xsl:variable name="theUrl" select = "concat($thePage, '/', $theLoc, '?', number($pageNumber+1))"/>

    then your link statement

    <a href="{$theUrl}">next</a>

    Now, couple disclaimers... this code is not tested... and others may chose to do it differently. For teaching purposes, i tried to step through with assigning variables and demonstrating a concat... some may chose to do it all in one line.

    Hope this helps.

  • trfletch 598 posts 604 karma points
    Apr 29, 2010 @ 17:35
    trfletch
    1

    Hi Chris, thanks for the response, I don't think you fully understand what I am trying to do, this is a search results page so it is showing the results depending on what someone seleted in a form on the previous page, therefore when it creates the page with 10 results for example it needs to have a link to show the next 10 results therefore the link needs to include the querystring results that were submitted with the form.

    Hi Bob, thanks for the response that is exactly what I needed, I already have a variable for the querystring so it was just a case of creating a variable for the "thePage". I am now in the process of creating variables for "previousURL" and one to link directly to the page number.

  • bob baty-barr 1180 posts 1294 karma points MVP
    Apr 29, 2010 @ 21:13
    bob baty-barr
    0

    cool! glad it worked and thx for the karma!

Please Sign in or register to post replies

Write your reply to:

Draft