If you are using umbracoNaviHide in your foreach code you should just be able to do this:
@foreach(var child in Umbraco.GetDynamicContentById(source).Children.Where("Visible")) { //code here }
This will only select nodes which are visible. This is how it works in umbraco 4.7 anyhow I haven't built a site in v5 as yet so can't say I have tested it.
@DynamicModel represents the current page you are processing. So, the first loop starts from the page being viewed and goes up in the tree hierarchy until it finds the actual homepage.
I'm not sure if it works in 5.0, but in 4.7 you could also get there via @DynamicModel.AscendantsOrSelf("homePage"). Might be worth a try in 5.0 as well.
string is not recognized as valid boolean
hi i have followed the following steps in creating navigation macro in umbraco 5.0.1 from the following website
http://www.eyecatch.no/blog/2012/03/simple-navigation-macro-for-umbraco-5/
However i get an error at this point in the macro partial ----navigation code
@inherits PartialViewMacroPage
@using Umbraco.Cms.Web
@using Umbraco.Cms.Web.Macros
@using Umbraco.Framework
@{ var source = string.IsNullOrEmpty(Model.MacroParameters.Source) ? Model.CurrentPage.Id : Model.MacroParameters.Source; }
<ul>
@foreach(var child in Umbraco.GetDynamicContentById(source).Children) {
if (child.umbracoNaviHide != null && !bool.Parse(child.umbracoNaviHide)) {
var activeClass = (Model.CurrentPage.Id == child.Id ? "active" : "");
<li><a href="@child.NiceUrl" class="@activeClass"><span>@child.Name</span></a></li>
}
}
</ul>
at the time of debugging as string is not recognised as valid boolean type
I am complete newbie and it wold be great if someone solves my problem
I am sorry for my utterly bad explanation ....but can someone please guide me towards my goal to make a navigation bar in umbraco 5.0.
This isnt solved.Sorry for the error caused
Hi,
If you are using umbracoNaviHide in your foreach code you should just be able to do this:
This will only select nodes which are visible. This is how it works in umbraco 4.7 anyhow I haven't built a site in v5 as yet so can't say I have tested it.
John
hi John thanks for coming up with a reply.The below code is in partial views ===> navigation.cshtml file.Can you please say how this
@DynamicModel is taking the content
Hi,
@DynamicModel represents the current page you are processing. So, the first loop starts from the page being viewed and goes up in the tree hierarchy until it finds the actual homepage.
I'm not sure if it works in 5.0, but in 4.7 you could also get there via @DynamicModel.AscendantsOrSelf("homePage"). Might be worth a try in 5.0 as well.
Cheers,
Michael.
Thanks for the help @Michael
You're welcome :-)
rootNode.Children.Where("umbracoNaviHide != \"True\"").Any();
Hi guys I'm trying this... any ideas why it isn't working in v5?
is working on a reply...