Copied to clipboard

Flag this post as spam?

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


  • Mike Taylor 155 posts 353 karma points
    Oct 28, 2009 @ 11:27
    Mike Taylor
    0

    nodeTypeAlias - how to get inherited document type?

    I want to select only those nodes which inherit from a base document type - as far as I can tell, nodeTypeAlias only uses the alias of the current node and doesn't take its inheritance into account.

    <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=1]/node [string(data [@alias='umbracoNaviHide']) != '1'][((( inherits from document type 'xxxx' )))]">

    Any ideas?

    Mike

  • dandrayne 1138 posts 2262 karma points
    Oct 28, 2009 @ 11:40
    dandrayne
    0

    It doesn't seem to be stored in the node

    <node 
    id="1076"
    version="f4b05a70-c7a2-4e3b-a52f-d5a79eb06d23"
    parentID="1050"
    level="2"
    writerID="0"
    creatorID="0"
    nodeType="1043"
    template="1044"
    sortOrder="3"
    createDate="2009-09-30T15:31:29"
    updateDate="2009-10-27T17:19:07"
    nodeName="Primary"
    urlName="primary"
    writerName="Administrator"
    creatorName="Administrator"
    nodeTypeAlias="TextPage"
    path="-1,1050,1076">

    So it may need to be a case of finding from the document type in 'settings' which nodes inherit and putting the nodeTypeAlias' in the for-each manually...

    Unless someone has more info?

    Dan

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Oct 28, 2009 @ 11:54
    Lee Kelleher
    0

    Mike, could you hook on to any unique properties on the parent docType?

    For example, lets say you have a parent docType called "BaseDocType" and a property in it called "inheritedDocType". Then in the XSLT you can do this:

    <xsl:for-each select="$currentPage/ancestor-or-self::node[@level=1]/node[@nodeTypeAlias != 'BaseDocType' and count(data[alias='inheritedDocType']) &gt; 0 and string(data[@alias='umbracoNaviHide']) != '1']">
        <xsl:value-of select="@nodeName" />
    </xsl:for-each>

    Here is what is happening in the select... the first condition is checking that it not the base doc-type, the second is checking if it has the inherited property, and the third is your usual 'umbracoNaviHide' test.

    It would be much nicer to have a node-level attribute/property called "parentNodeAlias", but then where do you draw the line, as you have several nested doc-types ... unless they went down the @path route? (with comma-separated doc-type ids).

    Let me know if it works out!

    Cheers, Lee.

  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Oct 28, 2009 @ 11:55
    Chris Houston
    0

    Hi Mike,

    I think Dan is probably right. What are you trying to do? Maybe there is another way to solve your problem?

    Chris

  • Mike Taylor 155 posts 353 karma points
    Oct 28, 2009 @ 12:11
    Mike Taylor
    0

    Under my home page, I have several pages (some standard pages, maybe some other pages which inherit from a standard page - like a 'section page'), but I also have a couple of folders for pages which will go in header and footer navigation elements. In my primary nav xslt, I'm trying to exclude everything under the home element which isn't something which inherits from a standard page.

    I could list all the inherited types, or conversely I could select everything except the folder types - I just thought that if there was a quick way to select nodes based on their inherited type, that would be a tidy way of doing it.

    Thanks for your help,

    Mike

  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Oct 28, 2009 @ 12:39
    Chris Houston
    1

    If I understand you correctly, you currently have the following structure:

    home
    home/blog/blog post
    home/etc.....
    home/footerfolder/terms and conditions
    home/headerfolder/contact us

    Why not move the footer & header folders up to the root of your content structure?

    Another option is to add a couple more parameters, I.e. umbracoNaviFooterHide / umbracoNaviHeaderHide ( or the opposite... "show" )

    Cheers,

    Chris

  • Mike Taylor 155 posts 353 karma points
    Oct 28, 2009 @ 12:54
    Mike Taylor
    0

    I want to keep the header and footer folders underneath the 'home' node because there's a chance this could be a multilingual site. Lots to consider... :-)

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Oct 28, 2009 @ 13:02
    Lee Kelleher
    0

    Personally I think the true/false switches for header/footer links (as Chris mentioned) is the way to go ... it's a more scalable solution.

  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Oct 28, 2009 @ 13:13
    Chris Houston
    0

    Hi,

    I usually have a top level node called "site" which holds site wide parameters, this could be where your multiple lingual seperation happens as you'd have multiple site's each with their own "home" / "footer" / "header" sections.

    Just an idea :)

    Cheers,

    Chris

  • Chad Rosenthal 272 posts 474 karma points
    Oct 28, 2009 @ 14:00
    Chad Rosenthal
    0

    One of the advantages of Master Templates is that all of the children inherit all of the data types. Since this is the case, you can add a datatype to the master template, similar to the UmbracoHideNavi checkbox that the navigation will look for. Since the folder's don't inherit this data type, then the folders will not display.

  • Mike Taylor 155 posts 353 karma points
    Oct 28, 2009 @ 15:37
    Mike Taylor
    0

    Chris,

    That sounds interesting --- quick question though - how do you prevent NiceUrl links from reading "/home/section/page.aspx"? (I wouldn't want the "/home/" part in there...

    Cheers,

    Mike

  • dandrayne 1138 posts 2262 karma points
    Oct 28, 2009 @ 16:23
    dandrayne
    0

    Does the "hideTopLevelNodeFromPath" setting not do that?  It's in umbracosettings.config  (I think!)

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Oct 28, 2009 @ 16:51
    Lee Kelleher
    0

    @Dan: "umbracoHideTopLevelNodeFromPath" is in the Web.config ;-)

  • dandrayne 1138 posts 2262 karma points
    Oct 28, 2009 @ 17:36
    dandrayne
    0

    Ah, probably should check these things instead of dropping disclaimers!

  • Mike Taylor 155 posts 353 karma points
    Oct 28, 2009 @ 17:36
    Mike Taylor
    0

    The hideTopLevelNodeFromPath setting is already true; Chris was suggesting a structure like this, to enable a multi-lingual approach, but also to logically separate normal site content from header and footer elements:

    + Content (root)

         + Site

              + Home

                   (normal site content pages)

              + Header

                   (header navigation pages - glossary, downloads, site map etc)

              + Footer

                   (footer navigation pages - accessibility, privacy policy etc)

    In this instance, I want to hide both "Site" and "Home" from the path. I'm starting to think this may not be the best approach?
    Cheers,
    Mike

  • dandrayne 1138 posts 2262 karma points
    Oct 28, 2009 @ 18:32
    dandrayne
    0

    Taking it back to the original problem, I'm not sure why you'd want to do it this way.  Obviously there's more than one way to skin a cat, but for "footer links" that don't fit anywhere else I usually put them under the homepage as with any other content page and set umbracoNaviHide to be true.  Then use treeMultiPicker on the homepage to allow editors to create the footer nav.

    As shown at http://i33.tinypic.com/2uonnt0.jpg

    The advantage of this is that often editors want to include "normal" pages in the footer, and using the treemultipicker  allows them to select any page in the site to be added to the footer and reorder them with drag & drop.

    Then to complete that the following xslt should display the footer nav on every page

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <xsl:variable name="homePageNode" select="$currentPage/ancestor-or-self::node [@nodeTypeAlias='Homepage']" />
    <xsl:if test="string($homePageNode/data [@alias='siteFooterLeft']) != ''">
    <ul class="nav footer_left">
    <xsl:variable name="relatedNodeSet" select="$homePageNode/data[@alias='siteFooterLeft']"/>
    <xsl:for-each select="$relatedNodeSet/descendant::node">
    <xsl:variable name="currentItem" select="umbraco.library:GetXmlNodeById(.)"/>

    <li>
    <a href="{umbraco.library:NiceUrl($currentItem/@id)}">
    <xsl:value-of select="$currentItem/@nodeName" />
    </a><xsl:text> / </xsl:text>
    </li>

    </xsl:for-each>

    </ul>
    </xsl:if>

    </xsl:template>

    </xsl:stylesheet>

    Using this method it may seem to clutter the main level under the homepage in the tree, but these (privacy policy) are real site pages so why should they be hidden away?  If you need to hide them, then create a folder called something innocuous like "site" and pop them in there.

    Hope this helps,
    Dan

     

     

  • Mike Taylor 155 posts 353 karma points
    Oct 29, 2009 @ 10:06
    Mike Taylor
    0

    Hi Dan - this seems like a really tidy solution, thanks for your help.

    Mike

  • Saxon 10 posts 31 karma points
    May 07, 2010 @ 18:04
    Saxon
    0

    Hi there - it looks like you solved the problem, but I thought I'd toss in my 2 cents because I had a similar issue and used a bit of a workaround - I'm relatively new to Umbraco so please feel free to shoot it down ;)

    Due to the project specs and the way I've handled the inheritance, I need to display all pages that inherit from a specific master page and have a given tag - I used a naming convention and filtered by "contains" rather than an exact match to the parent type - every document type under the "ContentPage" doc type has "ContentPage" in its alias (ie "ContentPage2Column"):

      
    
    

    Is there a more elegant way?

    Cheers, Saxon

  • Saxon 10 posts 31 karma points
    May 07, 2010 @ 18:08
    Saxon
    0

    sigh, new to the boards, sorry about that....

    <xsl:for-each select="umbraco.library:GetXmlNodeById(number($source))/descendant::node [contains(@nodeTypeAlias,'ContentPage') and contains(Exslt.ExsltStrings:lowercase(./data [@alias='Categories']), Exslt.ExsltStrings:lowercase(string($filter)))]">
      <!-- node code -->
    </xsl:for-each>
    
Please Sign in or register to post replies

Write your reply to:

Draft