Copied to clipboard

Flag this post as spam?

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


  • Arie 224 posts 675 karma points
    Dec 10, 2012 @ 23:16
    Arie
    0

    Exclude certain pages from the results?

    It's a great package, but I was wondering if it's possible to exclude certain pages. I assume it's already ignoring pages that have "naviHide" set to true, but it would be great if there were a variable (e.g. "hideFromSearchResults") that could be used to suppress specific pages.

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Dec 11, 2012 @ 10:33
    Douglas Robar
    0

    Hi, Arie,

    No problem at all. You would want to add a property to any document type(s) you want to filter out of the search results, just like you do with the umbracoNaviHide property. As you suggest, the 'hideFromSearchResults' property alias is a good one.

    Then, modify the xsltsearch.xslt file looking for the 'possibleNodes' variable, adding the line in bold for your new property

    <xsl:variable name="possibleNodes" select="$items/descendant-or-self::*[
                                 @isDoc
                                 and string(umbracoNaviHide) != '1'
                                 and string(hideFromSearchResults) != '1'
    <!-- Hide documents from search -->
                                 and count(attribute::id)=1
                                 and (umbraco.library:IsProtected(@id, @path) = false()
                                  or umbraco.library:HasAccess(@id, @path) = true())
                               ]"/>
    This way, only pages that are not hidden from the navigation and are also not specifically hidden from the search results will appear in the results.
    cheers,

    doug. 

  • jeff 1 post 21 karma points
    Dec 13, 2012 @ 18:10
    jeff
    0

    Doug, Thanks for the info as well. Is it possible to exclude all childen nodes under a specific parent node?

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Dec 18, 2012 @ 22:06
    Douglas Robar
    0

    Hi, Jeff,

    The default code doesn't hide things 'recursively'. By default you'd need to set the umbracoNaviHide or hideFromSearchResults property on every page you wanted to hide. I think this is reasonable but if you'd prefer to hide a page and all those below it you would modify the code to:

    <xsl:variable name="possibleNodes" select="$items/descendant-or-self::*[
                                 @isDoc
                                 and not(ancestor-or-self::*/umbracoNaviHide) = 1
                                 
    and not(ancestor-or-self::*/hideFromSearchResults) = 1
    <!-- Hide documents from search -->
                                 and count(attribute::id)=1
                                 and (umbraco.library:IsProtected(@id, @path) = false()
                                  or umbraco.library:HasAccess(@id, @path) = true())
                               ]"/>

     This checks the umbracoNaviHide and hideFromSearchResults not just on each page but all the setting on all of its ancestors as well.

     

    Not thoroughly tested but I believe this is what you're looking for.

    Do be very careful to add a complete description to the document type property alias so that your content editors realize how powerful this is. And that once set there is no way to allow a child page to be included in the search results again. At least not without more checks and logic in the possibleNodes variable.

    cheers,
    doug. 
Please Sign in or register to post replies

Write your reply to:

Draft