XsltSearch returns children of node that has umbracoNaviHide set to one
Hi all,
I wonder if I'm doing something wrong here, but I'm using an un-modified version of XSLT (version 2.8.1) at the moment. In my site I have a folder which contains sidebar items. The folder has umbracoNaviHide set to 1. The sidebar items do not have this property at all - they do not exist as standalone pages on the site. There are hundreds of these items, with many different documenttypes.
I considered changing the possiblenodes variable so that any child (grandchild, etc) of this node would be excluded from the resultset, but I haven't been successful in this. I tried this kind of thing, but no joy:
<xsl:variable name="possibleNodes" select="$items/descendant-or-self::*[ @isDoc and string(umbracoNaviHide) != '1' and count(attribute::id)=1 and ancestor-or-self::RHSItemsFolder/local-name = '' and (umbraco.library:IsProtected(@id, @path) = false() or umbraco.library:HasAccess(@id, @path) = true()) ]"/>
umbracoNaviHide is only used to hide in navigation. If you don't want it to show up .. simply unpublish or modify the XSLT to exclude nodes with the value set.
Thanks for your reply but I can't unpublish these sidebar items as they are used across the site - they just do not exist as standalone pages (and so I can't have them appear as links on the search results page). Also, the sidebar items do not have the umbracoNaviHide property - but their parent folder does. I would have thought that if the folder had it set then the child nodes would not be included, but that doesn't seem to be the case.
Yeah but the problem I have just now is that there are loads of these document types - I'd rather somehow exclude all items below that specific folder from the search results.
because there are two levels of nodes below the folder in question, and it's a multilingual site so I can't hardcode the folder id. I need to check both parent and grandparent explicitly as using ancestor-or-self would include the result - I need items whose parent and grandparent are BOTH not the folder in question.
Instead of ancestor-or-self:: you could use ancestor:: to not include the result itself. Also, the "XSLT-idiomatic" way of writing something != something-else is to flip it and use the not() function:
XsltSearch returns children of node that has umbracoNaviHide set to one
Hi all,
I wonder if I'm doing something wrong here, but I'm using an un-modified version of XSLT (version 2.8.1) at the moment. In my site I have a folder which contains sidebar items. The folder has umbracoNaviHide set to 1. The sidebar items do not have this property at all - they do not exist as standalone pages on the site. There are hundreds of these items, with many different documenttypes.
I considered changing the possiblenodes variable so that any child (grandchild, etc) of this node would be excluded from the resultset, but I haven't been successful in this. I tried this kind of thing, but no joy:
Any ideas?
Thanks!
David
umbracoNaviHide is only used to hide in navigation. If you don't want it to show up .. simply unpublish or modify the XSLT to exclude nodes with the value set.
Hi Daniel,
Thanks for your reply but I can't unpublish these sidebar items as they are used across the site - they just do not exist as standalone pages (and so I can't have them appear as links on the search results page). Also, the sidebar items do not have the umbracoNaviHide property - but their parent folder does. I would have thought that if the folder had it set then the child nodes would not be included, but that doesn't seem to be the case.
David
You could also skip specific sidebar node types.
I've done it before with a simple addition to XSLTSearch when it displays the result links
Find in XSLTsearch.xslt for <xsl:for-each select="$matchedNodes">
Replace with <xsl:for-each select="$matchedNodes [@nodeTypeAlias != 'SidebarNode']">
Yeah but the problem I have just now is that there are loads of these document types - I'd rather somehow exclude all items below that specific folder from the search results.
Then try this:
<xsl:for-each select="$matchedNodes [./parent::node/@id != '1234']">
where 1234 is your parent node id containing all sidebar nodes
Thanks very much for your help, Daniel - it definitely put me on the right track. I replaced this:
with this:
because there are two levels of nodes below the folder in question, and it's a multilingual site so I can't hardcode the folder id. I need to check both parent and grandparent explicitly as using ancestor-or-self would include the result - I need items whose parent and grandparent are BOTH not the folder in question.
Anyway, it works now. Thanks again!
David
Hi David,
Instead of ancestor-or-self:: you could use ancestor:: to not include the result itself. Also, the "XSLT-idiomatic" way of writing something != something-else is to flip it and use the not() function:
/Chriztian
David,
Glad to assist. Great news that it's working for you.
Chriztian,
Totally spaced the not() method. Thanks!
Nice one Chriztian, using the not method is a lot neater.
is working on a reply...