Copied to clipboard

Flag this post as spam?

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


  • Grant 6 posts 26 karma points
    Jan 22, 2014 @ 05:10
    Grant
    0

    Menu Builder - Brainstorming

    Hey so I need some help thinking through a thought process here. I have created the following xslt script to create menus using the uComponent - Multi Node Tree Picker.

    <?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" xmlns:Examine="urn:Examine" xmlns:ucomponents.cms="urn:ucomponents.cms" xmlns:ucomponents.dates="urn:ucomponents.dates" xmlns:ucomponents.email="urn:ucomponents.email" xmlns:ucomponents.io="urn:ucomponents.io" xmlns:ucomponents.media="urn:ucomponents.media" xmlns:ucomponents.members="urn:ucomponents.members" xmlns:ucomponents.nodes="urn:ucomponents.nodes" xmlns:ucomponents.random="urn:ucomponents.random" xmlns:ucomponents.request="urn:ucomponents.request" xmlns:ucomponents.search="urn:ucomponents.search" xmlns:ucomponents.strings="urn:ucomponents.strings" xmlns:ucomponents.urls="urn:ucomponents.urls" xmlns:ucomponents.xml="urn:ucomponents.xml" 
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets Examine ucomponents.cms ucomponents.dates ucomponents.email ucomponents.io ucomponents.media ucomponents.members ucomponents.nodes ucomponents.random ucomponents.request ucomponents.search ucomponents.strings ucomponents.urls ucomponents.xml ">

    <xsl:output method="xml" omit-xml-declaration="yes" />
    <xsl:param name="currentPage"/>
    <xsl:variable name="level" select="1"/>
    <xsl:template match="/">
    <xsl:if test="$currentPage/MenuPicker/menuBuilder/MultiNodePicker/nodeId">
    <ul class="list-unstyled sideMenu">
    <xsl:for-each select="$currentPage/MenuPicker/menuBuilder/MultiNodePicker/nodeId">
            <li>
    <xsl:variable name="currentnode" select="umbraco.library:GetXmlNodeById(.)" />
            <!-- render only published nodes -->
            <xsl:if test="count($currentnode/error) = 0">           
    <a href="{umbraco.library:NiceUrl($currentnode/@id)}">
    <xsl:value-of select="$currentnode/@nodeName" />
    </a>
            </xsl:if>
    </li>
        </xsl:for-each>
    </ul>
    </xsl:if>
    </xsl:template>
    </xsl:stylesheet>

    Now while I am satisfied with my work for now and it works just fine. How would one go about extending this to allow and test for multiple menus? Say I want to title this "quick menu" and add another menu "user menu". I know my following will just generate the list in both places.

    So my menu builder is a doc type with the node picker but if a client were to add another menu builder under node that is where I see the issues coming in. 

    Thoughts?

    I will need some sort of count test correct?

    Thanks in advanced!

     

  • Kasper Dyrvig 246 posts 379 karma points
    Feb 11, 2014 @ 15:08
    Kasper Dyrvig
    0

    Hi Grant

    Here is a thought: You could add a property to the macro where you specify what menubuilder-node the menu should be builded from.

  • Grant 21 posts 61 karma points
    Feb 18, 2014 @ 06:42
    Grant
    0

    Thanks, yeah this worked.

Please Sign in or register to post replies

Write your reply to:

Draft