Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 939 posts 2574 karma points
    Aug 20, 2009 @ 09:22
    Claushingebjerg
    0

    exclude document type from xsltsearch

    Is there an easy way to exclude a certain document type from being searched by xslt search?

     

    For example, i have a document type on my site called "Variant" which i do not want to be searchable. Moving it outside the scope of xslt search is not an option. Wahat im looking for is a small tweak to the xslt that leaves out the "Variant" document type from the search.

     

    Thanks

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Aug 20, 2009 @ 09:38
    Dirk De Grave
    1

    hi,

    think only tweak that's necessary is to filter the nodes even more (find snippet in xslt code):

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

    Add an extra restriction on document type as in @nodeTypeAlias != 'Variant'

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

    Other solutions may exist of course, and also like to hear about those

     

    Hope this helps.

     

    Regards,

    /Dirk

  • Bert 128 posts 251 karma points
    Aug 20, 2009 @ 09:49
    Bert
    0

    Add:

    and [@nodeTypeAlias '= 'Variant']

    To this select statement.

           <!-- reduce the number of nodes for applying all the functions in the next step -->
    <xsl:variable name="possibleNodes" select="$items/descendant-or-self::node[
    string(data [@alias='umbracoNaviHide']) != '1'
    and count(attribute::id)=1
    and (umbraco.library:IsProtected(@id, @path) = false()
    or umbraco.library:HasAccess(@id, @path) = true())
    ]"/>
  • Roel 151 posts 305 karma points
    Aug 20, 2009 @ 11:01
    Roel
    0

    I did this once using an extra property on the document type. By default you can use the umbracoNavihide property to hide a certain content item from the navigation. To be consistent I created a new property called "umbracoSearchhide". When you do this you can check in your XSLT if the property is set to "true" if so, make sure you won't let the item come up in the search results.

    Difference with this approach it's you will have to set the property per content item. It's not really on document type level like you asked. But this might also be a way to look at it.

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Aug 20, 2009 @ 11:12
    Douglas Robar
    100

    Here's a blog post I made about customizing xsltsearch for specific needs. It's a simple change to the xslt as Dirk and Bert both mentioned. I also agree with Roel about making a separate property for hiding from search.

    http://blog.percipientstudios.com/2009/4/7/customizing-xsltsearch.aspx

    cheers,
    doug.

  • Claushingebjerg 939 posts 2574 karma points
    Aug 20, 2009 @ 12:07
    Claushingebjerg
    0

    Once again this forum shows its worth. Thanks a lot guys! works like a charm

  • firepol 125 posts 173 karma points
    Nov 28, 2011 @ 12:00
    firepol
    0

    Let me update this post, because I use xslt search 3.0.4 and umbraco 4.7.1 and in my case the part to be modified looks already a bit different:

        <!-- 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 count(attribute::id)=1
                                 and (umbraco.library:IsProtected(@id, @path) = false()
                                  or umbraco.library:HasAccess(@id, @path) = true())
                               ]"/>

    After "@isDoc" just add the document types you don't need, by using the "name()" function (@nodeTypeAlias I think doesn't work anymore with the newest umbraco version). So e.g. (see in bold)

        <!-- 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 name() != 'Variant'
                                 and string(umbracoNaviHide) != '1'
                                 and count(attribute::id)=1
                                 and (umbraco.library:IsProtected(@id, @path) = false()
                                  or umbraco.library:HasAccess(@id, @path) = true())
                               ]"/>

    Hope this helps. Cheers

  • Gus Deadman 45 posts 65 karma points
    May 22, 2012 @ 14:06
    Gus Deadman
    0

    I've tried all of these trying to exclude Event items using a doc type called "EventItemcon" but none of them work for me which leads me to suppose I've done something small but significant that makes it not work. Is there anything I need to make sure I have done. All I've done is cut and paste and save the XSLT file back to appropriate directory in App_Data. Is there anything else I need to check or restart?

    Cheers

    Gus

    Scratch that I was using a different version of CWS Starter kit. I've now switchd to an earlier version and it works mostly. Thanks to Doug et al.

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 25, 2012 @ 11:23
    Fuji Kusaka
    0

    Has anyone been able to sort that out? 

    I have tried both solution but without success.

    and name() != 'dcoTypeName' nor @NodeTypeAlias !='dcoTypeName'
  • Jon Dunfee 199 posts 468 karma points
    Oct 25, 2012 @ 18:04
    Jon Dunfee
    0

    I actually add a field to the doc type to purposely hide from search, looks like the following:

    <xsl:variable name="possibleNodes" select="$items/descendant-or-self::*[
                             @isDoc
                             and string(template) != '0'
                             and string(hideFromSearch) != '1'
                             and count(attribute::id)=1 
                             and (umbraco.library:IsProtected(@id, @path) = false()
                              or umbraco.library:HasAccess(@id, @path) = true())
                           ]"/>
     

Please Sign in or register to post replies

Write your reply to:

Draft