Copied to clipboard

Flag this post as spam?

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


  • Cookie Monster 7 posts 27 karma points
    Dec 19, 2012 @ 07:48
    Cookie Monster
    0

    exclude multiple nodetypes from foreach

    Hi i have the following select

    <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc and @level=$level]/* [@isDoc and @nodeType != '1134' and string(umbracoNaviHide) != '1']">

    which works fine, however i now want to exclude another document type from the select, so i have done the following:

    <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc and @level=$level]/* [@isDoc and @nodeType != '1134' and @nodeType != '1177' and string(umbracoNaviHide) != '1']">

    Whaqt happens now is that it does not exclude the second document type and for some reason it now also does not exclude the first document type.

    I am using the latest umbraco version.

     

    Thanks !

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Dec 19, 2012 @ 08:07
    Chriztian Steinmeier
    0

    Hi Cookie Monster,

    I'd rewrite that to something like this:

    <xsl:for-each select="
        $currentPage/ancestor-or-self::*[@isDoc and @level = $level]
        /*[@isDoc and not(umbracoNaviHide = 1)]
        [not(@nodeType = 1134) and not(@nodeType = 1177)]
    ">

    * Find the ancestor (or self) at level $level,

    * take its child documents that are not hidden,

    * which are not any of the nodeTypes 1134 or 1177

    Instead of using the @nodeType attribute, it would actually be much clearer to use the Aliases of said document types, e.g.:

    <xsl:for-each select="
        $currentPage/ancestor-or-self::*[@isDoc and @level = $level]
        /*[@isDoc and not(umbracoNaviHide = 1)]
        [not(self::NewsList or self::PeopleContainer)]
    ">

     

    /Chriztian

  • Cookie Monster 7 posts 27 karma points
    Dec 19, 2012 @ 09:01
    Cookie Monster
    0

    Thanks Chriztian, it was exactly what i was looking for.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies