I was able to solve it. I looked at the type that GetProperty returned, and figured i used the wrong method. After some documentation searching i found the GetPropertyValue, which returns a string value. Is Razor using lazy evaluation? I figured that could be why i worked on level-2 nodes...
Actually its for i side bar navigation. I wanted the children shown in the menu to be the children of the closest mode where the property "rootnode" is set to true. I was able to solve it according to my reply above.
Using GetProperty-value in while loop
I am trying to create a Left Navigation Menu macro, using razor. I've run into one small issue though.
Consider my code
As you can see, it keeps going up from the own page until the level is 2 or the property "rootnode" is true.
On level 2 pages, this works. But on level 3 pages i get this error:
Error loading MacroEngine script (file: Leftnav.cshtml)
What am i doing wrong here, and how do i solve it?
I was able to solve it. I looked at the type that GetProperty returned, and figured i used the wrong method. After some documentation searching i found the GetPropertyValue, which returns a string value. Is Razor using lazy evaluation? I figured that could be why i worked on level-2 nodes...
Hi Anton
Not 100% sure what you are trying to create, but if you are using 4.11.1 MVC, you can achieve a breadcrumb type navigation by:
@CurrentPage.Up().NiceUrl()
If you want full navigation, try
@{
var updates = CurrentPage.AncestorOrSelf().Descendants();
}
foreach (var item in updates)
{
<a href="@item.NiceUrl()">@item.Name</a>
}
This will give you a list.
Hope this points you in the right direction.
Thank you for your reply Gary.
Actually its for i side bar navigation. I wanted the children shown in the menu to be the children of the closest mode where the property "rootnode" is set to true. I was able to solve it according to my reply above.
just in case you weren't aware... add ?umbDebugShowTrace=true to your url and make sure your web.config setting has debug enabled.
Then you can get an error message that is a little more descriptive than the Error loading MacroEngine script (...)
is working on a reply...