Copied to clipboard

Flag this post as spam?

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


  • Carlo Cabrales 58 posts 77 karma points
    Sep 08, 2010 @ 15:52
    Carlo Cabrales
    0

    Hide Nodetypes from Runway Drop Down Menu

    I'm having difficulties finding the answer from search so I'll just create a new thread.

    I installed the runway drop down menu package and created a news items. I'd like to hide the news items from populating in the drop down menu. My node type alias is "NewsItem" and the standard Runway Drop Down Menu package xslt looks like the following..

    I'd also like to apply this to FAQ nodestypes from the Runway FAQ module

     

    <?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" exclude-result-prefixes="msxml 
    umbraco.library">

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

        <xsl:param name="currentPage"/>

        <!-- update this variable on how deep your navigation should be -->
        <xsl:variable name="maxLevel" select="5"/>

        <xsl:template match="/">

            <xsl:value-of select="umbraco.library:AddJquery()"/>
            <xsl:value-of select="umbraco.library:RegisterJavaScriptFile('droppyJs', '/scripts/droppy.js')"/>
            <xsl:value-of select="umbraco.library:RegisterStyleSheetFile('droppyCss', '/css/dropdownnavigation.css')"/>

            <xsl:variable name="droppyJS">$(function() {$('#dropdownNavigation').droppy();});</xsl:variable>

            <xsl:value-of select="umbraco.library:RegisterClientScriptBlock('droppyJs', $droppyJS, true())"/>


            <ul id="dropdownNavigation">
                <xsl:call-template name="drawNodes">
                    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@level=1 and @isDoc]"/>
                </xsl:call-template>
            </ul>
        </xsl:template>

        <xsl:template name="drawNodes">
            <xsl:param name="parent"/>

            <xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
                <xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevel]">
                    <li>
                        <a href="{umbraco.library:NiceUrl(@id)}">
                            <xsl:value-of select="@nodeName"/>
                        </a>
                        <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevel]) &gt; 0">
                            <ul>
                                <xsl:call-template name="drawNodes">
                                    <xsl:with-param name="parent" select="."/>
                                </xsl:call-template>
                            </ul>
                        </xsl:if>
                    </li>
                </xsl:for-each>
            </xsl:if>
        </xsl:template>
    </xsl:stylesheet>
  • Sascha Wolter 615 posts 1101 karma points
    Sep 08, 2010 @ 17:13
    Sascha Wolter
    0

    Hi Carlo,

    you can easily exclude news items from the list by replacing this line

    <xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevel]">

    with this

    <xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevel and @nodeTypeAlias != 'NewsItem']">

    If you want to exclude the FAQ items as well you just need to add another

    and @nodeTypeAlias != 'your_other_type'

    to the list.

    Hope that helps,

    Sascha

  • Carlo Cabrales 58 posts 77 karma points
    Sep 08, 2010 @ 18:07
    Carlo Cabrales
    0

    Thats what I added before but then everytime I reloaded my page, my menu disappeared. I'm an Umbraco newb so I'm not sure how to debug this.. This is what I changed it to..

     <?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" exclude-result-prefixes="msxml
    umbraco.library">
        <xsl:output method="xml" omit-xml-declaration="yes"/>
        <xsl:param name="currentPage"/>
        <!-- update this variable on how deep your navigation should be -->
        <xsl:variable name="maxLevel" select="5"/>
        <xsl:template match="/">
            <xsl:value-of select="umbraco.library:AddJquery()"/>
            <xsl:value-of select="umbraco.library:RegisterJavaScriptFile('droppyJs', '/scripts/droppy.js')"/>
            <xsl:value-of select="umbraco.library:RegisterStyleSheetFile('droppyCss', '/css/dropdownnavigation.css')"/>
            <xsl:variable name="droppyJS">$(function() {$('#dropdownNavigation').droppy();});</xsl:variable>
            <xsl:value-of select="umbraco.library:RegisterClientScriptBlock('droppyJs', $droppyJS, true())"/>

            <ul id="dropdownNavigation">
                <xsl:call-template name="drawNodes">
                    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@level=1 and @isDoc]"/>
                </xsl:call-template>
            </ul>
        </xsl:template>
        <xsl:template name="drawNodes">
            <xsl:param name="parent"/>
            <xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
                <xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevel and @nodeTypeAlias != 'NewsItem']">
                    <li>
                        <a href="{umbraco.library:NiceUrl(@id)}">
                            <xsl:value-of select="@nodeName"/>
                        </a>
                        <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevel]) &gt; 0">
                            <ul>
                                <xsl:call-template name="drawNodes">
                                    <xsl:with-param name="parent" select="."/>
                                </xsl:call-template>
                            </ul>
                        </xsl:if>
                    </li>
                </xsl:for-each>
            </xsl:if>
        </xsl:template>
    </xsl:stylesheet>
  • Carlo Cabrales 58 posts 77 karma points
    Sep 08, 2010 @ 19:06
    Carlo Cabrales
    0

    this worked!

     

                <xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1' and @nodeType != '1083' and @level &lt;= $maxLevel]">
                    <li>
                        <a href="{umbraco.library:NiceUrl(@id)}">
                            <xsl:value-of select="@nodeName"/>
                        </a>
                        <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1' and @nodeType != '1083' and @level &lt;= $maxLevel]) &gt; 0">
  • Sascha Wolter 615 posts 1101 karma points
    Sep 08, 2010 @ 21:32
    Sascha Wolter
    0

    Interesting, glad you figured it out! :)

  • Justin Moore 41 posts 100 karma points
    Sep 13, 2010 @ 03:08
    Justin Moore
    0

    with the new schema you can exclude nodes by type using :

     select="$currentPage/*[not(self::NewsItem)]">

     

    in the pre 4.5 schema you could use:

     select="$currentPage/node [@nodeTypeAlias!='NewsItem']">

    http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/xslt-examples-updated-to-new-schema

     

Please Sign in or register to post replies

Write your reply to:

Draft