<xsl:if test="count(./node [string(./data [@alias='verticalMenuHide']) != '1' and @level <= $maxLevelForSitemap and @nodeTypeAlias!='Newsarticle']) > 0 ">
As you can see it checks if the nodetypealias is NOT "Newsarticle", I aslo what to make it so that it checks to make sure it is NOT "Archivenewsarticle" but I am not sure how I modify the XSLT to do so. I assume I need some kind of "or" statement with the nodetypealias but I don't know what. Thanks for any help
You're missing ( ) = 0 around the @nodeTypeAlias statements. @nodeTypeAlias = 'something' returns a bool value. If we group this using ( ) with or in it and then check that it is false (0) you get what you want. Something in the line of
<xsl:if test="count(./node [string(./data [@alias='verticalMenuHide']) != '1' and @level <= $maxLevelForSitemap and (@nodeTypeAlias ='Newsarticle' or @nodeTypeAlias = 'Archivenewsarticle') =0]) > 0 ">
Thanks for your help, what I did in fact need was the following code, you pointed me in the right direction just that I didn't need the extra @nodeTypeAlias
<xsl:if test="count(./node [string(./data [@alias='verticalMenuHide']) != '1' and @level <= $maxLevelForSitemap and (@nodeTypeAlias ='Newsarticle' or 'Agilenewsarticle') =0]) > 0 ">
Sorry I lied, that didn't work, my code made it no show anything. If I use your code then it works for the Newsarticle one but not for the Archivenewsarticle
To explain how you'd approach a problem like this in XSLT, I'll start very simple:
To see if the current node has any <node> children you don't need the count() method, you'd simply write:
<xsl:if test="node"> ... </xsl:if>
The XPath you write in the test attribute will return a "set" and if that set doesn't contain any nodes, the test returns false().
You can further limit the nodeset by appending a number of "predicates" in square brackets - each added predicate will filter whatever was returned from the previous expression - so let's limit the nodes we want to only those with a level less-than or equal to $maxLevelForSitemap:
Hi, thank you everyone for the advice, thanks for the tips on how to write the XSLT Chriztian, I have pretty much taught myself XSLT by copying and modifying other peoples code so I am probably not writing it properly most of the time. I tried your method and initially it still did not work but I republished the pages in question and it started working so the other methods suggested probably would have also worked, it seems there was a problem with my site, so once again thank you everyone for your help.
Adding and "OR" statement for nodetypealias
Hi,
I have the following in my XSLT
As you can see it checks if the nodetypealias is NOT "Newsarticle", I aslo what to make it so that it checks to make sure it is NOT "Archivenewsarticle" but I am not sure how I modify the XSLT to do so. I assume I need some kind of "or" statement with the nodetypealias but I don't know what. Thanks for any help
This should do the job.
If you're new to xslt and have a small umbraco.config/site you can use Sketchpath to test your xpath statements.
Harald
Hi Harald,
I did already try the following but it didn't work, do I need to include the brackets somewhere?
You're missing ( ) = 0 around the @nodeTypeAlias statements. @nodeTypeAlias = 'something' returns a bool value. If we group this using ( ) with or in it and then check that it is false (0) you get what you want. Something in the line of
Hi Harald,
Thanks for your help, what I did in fact need was the following code, you pointed me in the right direction just that I didn't need the extra @nodeTypeAlias
Sorry I lied, that didn't work, my code made it no show anything. If I use your code then it works for the Newsarticle one but not for the Archivenewsarticle
How about
<xsl:if test="count(./node [string(./data [@alias='verticalMenuHide']) != '1' and @level <= $maxLevelForSitemap and @nodeTypeAlias!='Newsarticle' and @nodeTypeAlias!='Archivenewsarticle']) > 0 ">
Hi Morton,
Thanks for the response, I have already tried that but again it works for the Newsarticle but not for the Archivenewsarticle.
Please check the alias of the Archivenewsarticle. It is case sensitive.
That would be my guess as well. If it features two nodeTypeAlias statements and filter one of them correctly it's not the syntax.
Hi trfletch,
To explain how you'd approach a problem like this in XSLT, I'll start very simple:
To see if the current node has any <node> children you don't need the count() method, you'd simply write:
The XPath you write in the test attribute will return a "set" and if that set doesn't contain any nodes, the test returns false().
You can further limit the nodeset by appending a number of "predicates" in square brackets - each added predicate will filter whatever was returned from the previous expression - so let's limit the nodes we want to only those with a level less-than or equal to $maxLevelForSitemap:
(I ususally read this as "node having level less-than or equal to maxLevelForSitemap")
Now, let's add the nodeTypeAlias filter for Newsarticles:
- and let's add the other nodeTypeAlias filter right away:
- finally, we'll add the verticalMenuHide filter:
- and you're good to go!
/Chriztian
PS: As you can probably see, the "./" is never necessary in the beginning of an XPath; Likewise, the string() method is also almost never necessary.
Hi, thank you everyone for the advice, thanks for the tips on how to write the XSLT Chriztian, I have pretty much taught myself XSLT by copying and modifying other peoples code so I am probably not writing it properly most of the time. I tried your method and initially it still did not work but I republished the pages in question and it started working so the other methods suggested probably would have also worked, it seems there was a problem with my site, so once again thank you everyone for your help.
is working on a reply...