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.
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
<!-- 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()) ]"/>
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.
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.
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()) ]"/>
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.
I actually add a field to the doc type to purposely hide from search, looks like the following:
<xsl:variablename="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()) ]"/>
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
hi,
think only tweak that's necessary is to filter the nodes even more (find snippet in xslt code):
Add an extra restriction on document type as in @nodeTypeAlias != 'Variant'
Other solutions may exist of course, and also like to hear about those
Hope this helps.
Regards,
/Dirk
Add:
To this select statement.
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.
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.
Once again this forum shows its worth. Thanks a lot guys! works like a charm
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
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.
Has anyone been able to sort that out?
I have tried both solution but without success.
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())
]"/>
is working on a reply...