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
Hello everyone.
I am wondering how I could show only a few pages from my content tree, in my navigation.
This is what my content tree looks like
------------------------------------------------------------------------
Content
Home
Website
AdWords
SEO
References
Services
Contact
--------------------------------------------------------
What I wanna do, is hiding the "References" and "Services" pages in my navigation. How can I do that? Here is my script so far:
@{
var root = Model.AncestorOrSelf(1);
var homeActive = "";
if(root.Id == Model.Id){
homeActive = "active";
}
<ul class="nav navbar-nav navbar-right">
<li class="@homeActive">
<a href="@root.Url">@root.Name</a>
</li>
@foreach (var page in root.Children.Where("Visible"))
{
<li class="@page.IsAncestorOrSelf(Model, "active", "")">
<a href="@page.Url">@page.Name</a>
</ul>
Hi Jens,
You can restrict pages filtering by DocType or Name or Id, DocType is preferred way. Are your pages from different docTypes ?
Thanks, Alex
Hey Jens You Could add a property to your DocumentType and then in your code to check if that value is true.
This is what I am doing currently on my base DocumentType that is inherited by all my other main DocumentTypes:
Added a Property: Hide From Nav : umbracoNaviHide : True/False.
Then in my razor, I do this:
<ul class="nav"> @foreach (var childPage in Model.AncestorOrSelf(1).Children.Where("Visible")) { <li><a href="@childPage.Url">@childPage.Name</a></li> } </ul>
umbracoNaviHide is an Umbraco standard for the hiding of items from navigation.
Hope this is of some help
Phillip
Thank you so much Phillip! I didn't think of that.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Getting specific childpages to show in navigation
Hello everyone.
I am wondering how I could show only a few pages from my content tree, in my navigation.
This is what my content tree looks like
------------------------------------------------------------------------
Content
Home
Website
AdWords
SEO
References
Services
Contact
--------------------------------------------------------
What I wanna do, is hiding the "References" and "Services" pages in my navigation. How can I do that? Here is my script so far:
@{
var root = Model.AncestorOrSelf(1);
var homeActive = "";
if(root.Id == Model.Id){
homeActive = "active";
}
}
<ul class="nav navbar-nav navbar-right">
<li class="@homeActive">
<a href="@root.Url">@root.Name</a>
</li>
@foreach (var page in root.Children.Where("Visible"))
{
<li class="@page.IsAncestorOrSelf(Model, "active", "")">
<a href="@page.Url">@page.Name</a>
</li>
}
</ul>
Hi Jens,
You can restrict pages filtering by DocType or Name or Id, DocType is preferred way. Are your pages from different docTypes ?
Thanks, Alex
Hey Jens You Could add a property to your DocumentType and then in your code to check if that value is true.
This is what I am doing currently on my base DocumentType that is inherited by all my other main DocumentTypes:
Added a Property: Hide From Nav : umbracoNaviHide : True/False.
Then in my razor, I do this:
umbracoNaviHide is an Umbraco standard for the hiding of items from navigation.
Hope this is of some help
Phillip
Thank you so much Phillip! I didn't think of that.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.