When I go to the developer section and create a partial macro file - I first at hand used the navigation snippet to do a dynamic navigation
So that my navigation would look like this:
News in somali - News in English - About us - Contact
But then I created a new DocType "Category" and I allowed "News in somali and News in Somali" to be its children, so in the URL I would get:
www.mypage.com/category/news-in-somali
But then I was stucked, because the navigation snippet that I was using is only taking the root of the content tree's children pages (about us, contact us)
And it doesn't take the children pages' pages (news in somali and news in english)
I could just hard code it, but I want to make dynamic instead - and I used the umbracoNaviHide to hide category from the navigation
Alternatively, if your menu is only one level (i.e., no menu items under the top-level menu items), you can simply use a multinode treepicker to choose which nodes you want to include in the menu.
By the way, if you really must continue using whatever code snippet you are using, reply here with that code snippet and I'll take a look.
It gives me "About us", "Contact" and "Category" - but I don't want the category to be there, so I used the umbracoNaviHide - but I want its two children to be apart of the navigation.
I would recommend avoiding dynamic syntax (anytime you use "CurrentPage", you are using dynamic syntax). This should work given the structure you described:
@{
var home = Model.Content.AncestorOrSelf(1);
var selection = home.Children
.SelectMany(x => x.IsVisible()
? new[] { x }
: x.Children.Where(y => y.IsVisible()));
}
<ul>
@foreach (var item in selection)
{
<li class="@(item.IsAncestorOrSelf(Model.Content) ? "current" : null)">
<a href="@item.Url">@item.Name</a>
</li>
}
</ul>
However, I would still recommend a multinode treepicker or Archetype. They are more flexible solutions.
Making a navigation with categories
Hi guys
I'm making a news site. This news site has categories - so my content tree looks like this:
How do I make a navigation out of this? So it looks like this:
News in somali - News in english - About us - Contact
I would appreciate some help
//Sharmarke
Anyone?
Not sure what particular part you are having an issue accomplishing. Here are the high-level steps:
If your provide further details, we may be able to provide further insight.
When I go to the developer section and create a partial macro file - I first at hand used the navigation snippet to do a dynamic navigation
So that my navigation would look like this:
News in somali - News in English - About us - Contact
But then I created a new DocType "Category" and I allowed "News in somali and News in Somali" to be its children, so in the URL I would get:
www.mypage.com/category/news-in-somali
But then I was stucked, because the navigation snippet that I was using is only taking the root of the content tree's children pages (about us, contact us)
And it doesn't take the children pages' pages (news in somali and news in english)
I could just hard code it, but I want to make dynamic instead - and I used the umbracoNaviHide to hide category from the navigation
Hope this was understandable
Is there any reason you need to do it the way you are trying to do it?
I would really recommend Archetype for something like this: https://our.umbraco.org/projects/backoffice-extensions/archetype/
Alternatively, if your menu is only one level (i.e., no menu items under the top-level menu items), you can simply use a multinode treepicker to choose which nodes you want to include in the menu.
By the way, if you really must continue using whatever code snippet you are using, reply here with that code snippet and I'll take a look.
Sorry for not showing the snippet in my last reply - but I wasn't on my pc at that time. But here is the snippet:
@foreach (var item in selection) {-
@item.Name
}
It gives me "About us", "Contact" and "Category" - but I don't want the category to be there, so I used the umbracoNaviHide - but I want its two children to be apart of the navigation.
How do I achieve that?
I would recommend avoiding dynamic syntax (anytime you use "CurrentPage", you are using dynamic syntax). This should work given the structure you described:
However, I would still recommend a multinode treepicker or Archetype. They are more flexible solutions.
Could you give me a link to an article, documentation or a forum post about the multinode treepicker, because I've never used it before?
It is built in to Umbraco 7 and is one of the most useful property editors: https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/multinode-treepicker
In your case, you'd add a MNTP property (likely to your home node) and use it to pick the content nodes you want to be in your navigation menu.
Very nice!
Thank you for your help and time.
is working on a reply...