Copied to clipboard

Flag this post as spam?

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


  • Andy B 4 posts 24 karma points
    Sep 09, 2010 @ 16:38
    Andy B
    0

    Querystring - multiple values for single key

     

    I am creating a custom search using querystring and xslt for-each to list the results.

    I am unsure how I would go about manipulating multiple values for a single key in xslt.

     

    Example: single key is foodtype, multiple values are Italian, Indian, Thai...

    example.com?foodtype=Italian&foodtype=Indian&foodtype=Thai

     

    Now the below xslt returns a comma separated string of all that keys values; Italian,Indian,Thai .

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

     

    How can I separate this varying number of values into XSLT variables so I can use them in my for-each filter??

    <xsl:for-each select="$nodes [filter1] [filter2] [filter3] [filter4]">

    Also, there will be a varying number of filters, so how could I manage that?

     

    These posts got me started, but am now stuck on the above issue.

    http://our.umbraco.org/forum/developers/xslt/6751-Search-based-on-dropdowns-using-XSLT?p=0

    Thanks

  • Kim Andersen 1447 posts 2196 karma points MVP
    Sep 09, 2010 @ 17:32
    Kim Andersen
    0

    Hi Andy

    Maybe you can have a look at the Split-extension. This extension creates some new XML that you can use afterwards. Like this:

    <xsl:variable name="types" select="umbraco.library:Split(umbraco.library:RequestQueryString('type'),',')"/>

    The above variable would then contain the following XML:

    <values>
       
    <value>Italian</value>
       
    <value>Indian</value>
       
    <value>Thai</value>
    </values>

    I hope this can help you out somehow :)

    /Kim A

  • Sascha Wolter 615 posts 1101 karma points
    Sep 09, 2010 @ 21:03
    Sascha Wolter
    0

    Hi Andy,

    with regards to the varying number of filters (or filter types): you should have a default value vor each of these which you apply to them if there is no value provided. So let's say you can handle 5 filters filter1-filter5, you would then create 5 variables in your xsl script and do for each of them something like

    <xsl:variable name="filter1">
      <xsl:choose>
        <xsl:when test="umbraco.library:RequestQueryString('filter1') != '' ">
          <xsl:value-of select="umbraco.library:RequestQueryString('filter1')" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="number(0)" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    Hope that makes sense and helps,

    Sascha

     

Please Sign in or register to post replies

Write your reply to:

Draft