special style sheet for 2-/3-Level menus if exists

May 24, 2013 at 2:41 PM
Edited May 24, 2013 at 2:51 PM
Hi,

I'm building 1:1 mapping multi-language (DE, EN) with installed Polyglot in umbraco for our website, see: http://www.melnet.de, still in working.
By translation my til to 3 level menus I use macro associated with TranslatedNavigation.cshtml:
<umbraco:Macro UlCssId="" Level="2" NaviHideProperty="" CurrentItemCssClass="" TitlePropertyAlias="menuTitle" Alias="TranslatedNavigation" runat="server"></umbraco:Macro>
Each Page has common field alias "menuTitle". For 2-, 3-Level Menus we have special style sheet: transparent Box in Banner. How could I check in cshtml, if that menu has under-menu and only if yes, then comes that style sheet, else shold no happens. But now it appears nevertheless with empty box there, with polyglot.

here a sample if i use use umbraco xslt solution to disply 2-, 3-level menu:
<xsl:template match="/">

    <!-- start writing XSLT -->
    <xsl:variable name="items" select="$currentPage/ancestor-or-self::* [@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>  <!-- @level = 3 for 3. level -->
  
    <xsl:if test="count($items) &gt; 1">
        <div class="slider2_content">
            <div class="sidenav">
                <ul>
                    <xsl:for-each select="$items">
                        <li>
                <xsl:if test="@id = $currentPage/@id">
                                <xsl:attribute name="class">current</xsl:attribute>
                            </xsl:if>
                            <a href="{umbraco.library:NiceUrl(@id)}">
                                <xsl:value-of select="menuTitle"/>
                            </a>
                        </li>
                    </xsl:for-each>
                </ul>
            </div>
        </div>
   </xsl:if>
    
</xsl:template>
You see in XSLT, i can check at first if menu has under menu, then disply it with both div: "slider2_content" and "sidenav" where the special style sheet will be defeined in CSS.
But Solution with XSLT is not for multi-language.

Now I'm finding solution to cleanly reach that with your TranslatedNavigation.cshtml.

Thanks for your help!

-Jianchun
Coordinator
May 25, 2013 at 9:31 AM
Hi Jianchun,

If you are more comfortable with xslt than with Razor, you can use the XPath helper in Razor and select nodes using the same way you do in xslt.

There's information about that here:


I hope that this helps!

Best regards,

Dimitri