Copied to clipboard

Flag this post as spam?

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


  • Daniel Palm 36 posts 148 karma points
    Nov 26, 2014 @ 09:29
    Daniel Palm
    0

    Finding Search Id in Multinode Tree Picker

    Hi,

    When using the examine search I get this XML (simplified):

    <nodes>
      <node id="1394">
        <data alias="parentID">1755</data>
        <data alias="nodeName">Hinge BK5</data>
      </node>
    </nodes>

    The object, 1394, might be picked by a Multinode Tree Picker, like this:

    <Material id="1116">
      <materialTitle>Bridge 7</materialTitle>
      <materialParts>
         <MultiNodePicker type="content">
           <nodeId>1391</nodeId>
           <nodeId>1394</nodeId>
           <nodeId>2227</nodeId>
        </MultiNodePicker>
       </materialParts>
    </Material>

    How do I get the Id of <Material> 1116?

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Nov 26, 2014 @ 09:42
    Chriztian Steinmeier
    1

    Hi Daniel,

    You can get a set of all nodes that reference the node like this:

    <!-- This is the call that returns the nodes element - change that to how you're actually getting the Examine result -->
    <xsl:variable name="result" select="custom:search('something')" />
    
    <!-- Reference to site's root -->
    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    
    <!-- Find the Material node(s) that reference any node returned from the search -->
    <xsl:variable name="theyPickedMe" select="$siteRoot//Material[materialParts//nodeId = $result//node/@id]" />
    
    <!-- Render some output -->
    <xsl:apply-templates select="$theyPickedMe" />
    
    <!-- Template for Material output -->
    <xsl:template match="Material">
        <p><xsl:value-of select="@nodeName" /> : <xsl:value-of select="@id" /></p>
    </xsl:template>
    

    The important part is that you get a set - so if your search results in more than one node, you can get them all at once - if they're not all Material nodes just change the Material pattern to the more generic document selector: *[@isDoc].

    Hope that helps,

    /Chriztian

  • Daniel Palm 36 posts 148 karma points
    Nov 26, 2014 @ 10:15
    Daniel Palm
    100

    Thanks Chriztian, that worked like a charm.

Please Sign in or register to post replies

Write your reply to:

Draft