I have a site map where the i need to display all the pages and am actually using the ultimate structure. Everything is working just fine until i notice that some of the pages that needs has a value set to true (umbracoNaviHide) are showing up.
To be more precise this is how my structure looks like
* content --www --- EN ---- Folder 1 ----- Items (umbracoNaviHide set to true) ---- Folder 2 ----- Items ----- Items (umbracoNaviHide set to true) ----- Items (umbracoNaviHide set to true) ---- Folder (NEWS umbracoNaviHide set to true but child nodes should be displayed) ----- News Items ---- Folder (Media) ----- Media Items
This is how my razor code
@traverse(Model.NodeById(umbraco.library.GetDictionaryItem("sitePlan"))) @helper traverse(dynamic node) { var values = new Dictionary<string, object>(); var maxLevel = 5; values.Add("maxLevel", maxLevel); var items = node.Children.Where("Level <= maxLevel", values); if (items.Count() > 0) { <ul > @foreach (var pages in items) { if (pages.NodeTypeAlias == "section" || pages.NodeTypeAlias == "folder"){ <li>@pages.Name @traverse(pages)</li> } else{ <li><a href="@Library.If((pages.Children.Count() > 0 || pages.Where("jump")), pages.Children.First().Url, pages.Url)">@pages.Name</a> @traverse(pages)</li> } } </ul> } }
I think you should be able to check on "Visible" somewhere i the code above.
var items = node.Children.Where("Visible"); should do the trick - must admit that I'm not sure about how to write the syntax so you can check for both expressions. (Too much of a n00b at this still :D...Some would call me lazy).
var items = node.Children.Where("Visible" && "Level <= maxLevel", values); perhaps?...
Hide "umbracoNaviHide = 1" page
Hi,
I have a site map where the i need to display all the pages and am actually using the ultimate structure. Everything is working just fine until i notice that some of the pages that needs has a value set to true (umbracoNaviHide) are showing up.
To be more precise this is how my structure looks like
This is how my razor code
Hi Fuji
I think you should be able to check on "Visible" somewhere i the code above.
var items = node.Children.Where("Visible"); should do the trick - must admit that I'm not sure about how to write the syntax so you can check for both expressions. (Too much of a n00b at this still :D...Some would call me lazy).
var items = node.Children.Where("Visible" && "Level <= maxLevel", values); perhaps?...
Hope this helps.
/Jan
Hi Jan,
I did tried that as well but doing so will not display the Folders with umbracoNaviHide set to true.
is working on a reply...