Copied to clipboard

Flag this post as spam?

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


  • Søren Linaa 255 posts 208 karma points
    Jan 08, 2013 @ 14:24
    Søren Linaa
    0

    XSLT search - no template nodes

    I recently discovered that XSLT search is also returning nodes with no template asigned to them. 
    This means that the search results will link to invalid pages. 

    To overcome this I inserted one line in the xslt file. ' and @template > 0 '

    Can anyone see a problem with this approach

     

    Line 163:     
    <!-- reduce the number of nodes for applying all the functions in the next step -->
        <xsl:variable name="possibleNodes" select="$items/descendant-or-self::*[
                                 @isDoc
                                 and string(umbracoNaviHide) != '1'
    and @template > 0
                                 and count(attribute::id)=1 
                                 and (umbraco.library:IsProtected(@id, @path) = false()
                                  or umbraco.library:HasAccess(@id, @path) = true())
                               ]"/>

     

     

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Jan 08, 2013 @ 14:33
    Chriztian Steinmeier
    0

    Hi Søren,

    Nope - that should be fine - does it work? :-)

    /Chriztian

  • Søren Linaa 255 posts 208 karma points
    Jan 08, 2013 @ 14:34
    Søren Linaa
    0

    Of cause it does :-)

    just thought I would share.

  • LUIZ JUNIOR 4 posts 24 karma points
    Jan 08, 2013 @ 15:15
    LUIZ JUNIOR
    0

    My problem was sonthing like that, paths, that's the problem.

    I've created a Variable for node (items), where  ITEMS = ROOT, ITEMS2 = ../ROOT and ../../ROOT

    TRY THIS SAMPLE:

    <xsl:variable name="items" select="$currentPage/*[@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>
     <xsl:variable name="items2" select="$currentPage/../*[@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>
    <xsl:variable name="items3" select="$currentPage/../../*[@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>

     

    <xsl:if test="count($items) &gt; 0">
        <ul>
    <xsl:for-each select="$items">
      <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>    </xsl:if>

     

        <xsl:if test="count($items2) &gt; 0">
        <ul>
    <xsl:for-each select="$items2">
      <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>    </xsl:if>

     

          <xsl:if test="count($items3) &gt; 0">
        <ul>
    <xsl:for-each select="$items3">
      <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>    </xsl:if>
         

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Jan 08, 2013 @ 15:22
    Chriztian Steinmeier
    0

    Hi LUIZ,

    You should create a new thread so a thread doesn't cover many different issues - but you can do the same in a single chunk, using the ancestor-or-self:: axis:

    <xsl:variable name="items" select="$currentPage/ancestor-or-self::*[@level = 2]/*[@isDoc and not(umbracoNaviHide = 1)]" />
    <xsl:if test="$items">
        <ul>
            <xsl:for-each select="$items">
                <li>
                    <a href="{umbraco.library:NiceUrl(@id)}">
                        <xsl:value-of select="@nodeName"/>
                    </a>
                </li>
            </xsl:for-each>
        </ul>
    </xsl:if>

    /Chriztian 

  • 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