Copied to clipboard

Flag this post as spam?

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


  • Fredrik Esseen 610 posts 906 karma points
    Feb 27, 2014 @ 12:10
    Fredrik Esseen
    0

    XSLT Search and tags from MNTP

    Hi!

    I use the Multi Node Tree Picker to connect tags to my pages.

    The problem is that I want to let the search function (XSLTSearch) search through my tags to match related pages.

    My tags structure looks like this:

    I've looked at this thread that seems to relate to my problem: Including content picker in search results and tried to use the code. What I got so far is this:

    <?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"
        xmlns:PS.XSLTsearch="urn:PS.XSLTsearch"
        exclude-result-prefixes="msxml umbraco.library PS.XSLTsearch">
        <xsl:import href="XSLTsearch.xslt"/>
    
        <xsl:template match="/" priority="2">
    
      <!--Normal search-->
    
      <xsl:variable name="searchResults">
            <xsl:call-template name="search">
                <xsl:with-param name="items" select="$currentPage/ancestor-or-self::*[@level = 1]"/>
            </xsl:call-template>
        </xsl:variable>
    
      <xsl:variable name="results1" select="msxml:node-set($searchResults)"/>
    
    <!--Tags search-->
        <xsl:variable name="siteRoot" select="$currentPage/ancestor::root" />
        <xsl:variable name="possibleNodesProduct" select="$currentPage/ancestor::root//Tagg"/>
    
    <!-- generate a string of a semicolon-delimited list of all @id's of the matching nodes -->
    <xsl:variable name="matchedNodesIdListProduct">
      <xsl:call-template name="booleanAndMatchedNodes">
        <xsl:with-param name="yetPossibleNodes" select="$possibleNodesProduct"/>
        <xsl:with-param name="searchTermList" select="concat($searchUpper, ' ')"/>
      </xsl:call-template>
    </xsl:variable>
    
      <!-- get the actual matching nodes as a nodeset -->
      <xsl:variable name="matchedNodesProduct" select="$possibleNodesProduct[contains($matchedNodesIdListProduct, concat(';', concat(@id, ';')))]" />
    
      <!--Get the nodes which have MNTP point to the matched nodes.-->
    <xsl:variable name="relatedNodesProduct" select="$siteRoot//*[newTags/MultiNodePicker/nodeId = $matchedNodesProduct/@id]" />
    
      <xsl:variable name="productResults" select="msxml:node-set($relatedNodesProduct)"/>
    
      <!--Total search-->
      <xsl:variable name="total">
        <xsl:for-each select="$results1">
          <xsl:copy-of select="."/>
        </xsl:for-each>
        <xsl:for-each select="$productResults">
          <xsl:copy-of select="."/>
        </xsl:for-each>
      </xsl:variable>
    
      <xsl:variable name="results" select="msxml:node-set($total)"/>
    
        <xsl:apply-templates select="$results/div" />
    
    </xsl:template>
    
    </xsl:stylesheet>

    newTags is my document type for MNTP:

    But I dont get any results except the normal search.

    Anyone have any pointers?

  • 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