Copied to clipboard

Flag this post as spam?

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


  • Kim Andersen 1447 posts 2196 karma points MVP
    Jan 15, 2010 @ 10:46
    Kim Andersen
    0

    Variable source to search from

    In relation to my searchbox, I have made a dropdown-list over some content-nodes that the user can choose from. When a user choosen a node from the dropdown, I send a parameter called root as a querystring. This means that my URL looks like this after a search:

    /search.aspx?seach=word&root=1213

    The point is, that I want the ID in the root-parameter, as the source to my search.

    I thought that I could do I by changing the source-variable in the XSLT from:

    <xsl:variable name="source" select="string(ps:getParameter(string(//macro/source), '-1'))"/>

    to this:

    <xsl:variable name="root" select="umbraco.library:RequestQueryString('root')"/>
    <xsl:variable name="source" select="string(ps:getParameter(string($root), '-1'))"/>

    But this gives me 0 results.

    I have tried to write out the $source in a textarea, and when I write out the original $source I get a lot of text and numbers. But when I write out "my own" changed $source, I just get the ID from the root-parametre.

     

    But is it possible to make the source variable?

    I hope that you understand my problem :)

     

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jan 15, 2010 @ 12:50
    Douglas Robar
    0

    Here's how you'd do it...

    1. In the Settings section of umbraco, go to the Macros area and select the XSLTsearch macro

    2. Click the Parameters tab and change the 'source' field from 'Content Tree' to 'Content Picker'

    3. Save the XSLTsearch macro

    4. In the Settings section of umbraco, go to the XSLT Files area and select the XSLTsearch.xslt file

    5. Update the source variable as you've done and shown above

    6. In the <template match="/"> section, change the <xsl:otherwise> code to the following...

    <!-- search only within the SOURCE node specified in the macro and all of its children -->
    <xsl:call-template name="search">
        <xsl:with-param name="items" select="umbraco.library:GetXmlNodeById($source)/descendant-or-self::node"/>
    </xsl:call-template>

     

    That should do it!

    cheers,
    doug.

  • Kim Andersen 1447 posts 2196 karma points MVP
    Jan 15, 2010 @ 14:04
    Kim Andersen
    0

    Once again Doug - Thank you very much :) This worked just like I wanted it to.

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jan 15, 2010 @ 14:23
    Douglas Robar
    0

    You'e welcome!

    Please remember to mark the solution.

    cheers,
    doug.

Please Sign in or register to post replies

Write your reply to:

Draft