Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hey.
iam tryning to get the following topnavination menu convertede to a XSLT dut iam not so dam good in version 7 yet.
this is the one i use in my version 6 site in the scripting files.
@inherits umbraco.MacroEngines.DynamicNodeContext @{ @*Get the toot og the website *@ var root = Model.AncestorOrSelf(1).Children.Where("Visible"); } <ul> <li><a href="/">FORSIDE</a></li> @foreach (var page in root) { <li class="@page.IsAncestorOrSelf(Model, "current-menu-item", "")"> <a href="@page.Url">@page.Name</a> @* check if page has chrildren *@ @if (page.Children.Where("Visible").Count() > 0) { <ul> @foreach (var subpage1 in page.Children.Where("Visible")) { <li> <a href="@subpage1.Url">@subpage1.Name</a> } </li> } </ul> } </li> } </ul>
I love to get it over to XSLT. and i dit try but i cant get it to work.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]> <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:Examine="urn:Examine" exclude-result-prefixes="msxml umbraco.library Examine "> <xsl:output method="xml" omit-xml-declaration="yes" /> <xsl:param name="currentPage"/> <!-- Input the documenttype you want here --> <!-- Typically '1' for topnavigtaion and '2' for 2nd level --> <!-- Use div elements around this macro combined with css --> <!-- for styling the navigation --> <xsl:variable name="level" select="1"/> <xsl:template match="/"> <!-- The fun starts here --> <ul class="nav navbar-nav navbar-right"> <li> <a href="#" class="" data-toggle="dropdown">Velkommen</a> </li> <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc and @level=$level]/* [@isDoc and string(umbracoNaviHide) != '0']"> <li class="dropdown"> <a href="{umbraco.library:NiceUrl(@id)}" class="dropdown-toggle" data-toggle="dropdown"><xsl:value-of select="@nodeName"/></a> <ul class="dropdown-menu"> <li class=""> <a href="{umbraco.library:NiceUrl(@id)}" class="dropdown-toggle" data-toggle="dropdown"><xsl:value-of select="@nodeName"/></a> </li> </ul> </li> </xsl:for-each> </ul> </xsl:template> </xsl:stylesheet>
i hope som can help me..
i noly need it to list subpages one lvl down
like this.
page pagesub
Michael
Hi Michael,
Since you are using Umbraco 7 I can help you convert it to a partial view or partial view macro file.
Try to use this code below
@{ @*Get the toot og the website *@ var root = CurrentPage.AncestorOrSelf(1).Children.Where("Visible"); } <ul> <li><a href="/">FORSIDE</a></li> @foreach (var page in root) { <li class="@page.IsAncestorOrSelf(CurrentPage, "current-menu-item", "")"> <a href="@page.Url">@page.Name</a> @* check if page has chrildren *@ @if (page.Children.Where("Visible").Any()) { <ul> @foreach (var subpage1 in page.Children.Where("Visible")) { <li> <a href="@subpage1.Url">@subpage1.Name</a> } </li> } </ul> } </li> } </ul>
If you are using Partial view then you need to add this in the top of the file,
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
Try to see this documentation https://our.umbraco.org/documentation/Reference/Templating/Mvc/partial-views
If you are using a Partial view macro file, then you would need to add this to the top of the file.
@inherits Umbraco.Web.Macros.PartialViewMacroPage
Try to see the documentation here https://our.umbraco.org/documentation/Reference/Templating/Macros/Partial-View-Macros/ and https://our.umbraco.org/documentation/Reference/Templating/Mvc/views
Hope this helps,
/Dennis
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Dropdown Topnavigation problem.
Hey.
iam tryning to get the following topnavination menu convertede to a XSLT dut iam not so dam good in version 7 yet.
this is the one i use in my version 6 site in the scripting files.
I love to get it over to XSLT. and i dit try but i cant get it to work.
i hope som can help me..
i noly need it to list subpages one lvl down
like this.
page pagesub
Michael
Hi Michael,
Since you are using Umbraco 7 I can help you convert it to a partial view or partial view macro file.
Try to use this code below
If you are using Partial view then you need to add this in the top of the file,
Try to see this documentation https://our.umbraco.org/documentation/Reference/Templating/Mvc/partial-views
If you are using a Partial view macro file, then you would need to add this to the top of the file.
Try to see the documentation here https://our.umbraco.org/documentation/Reference/Templating/Macros/Partial-View-Macros/ and https://our.umbraco.org/documentation/Reference/Templating/Mvc/views
Hope this helps,
/Dennis
is working on a reply...