Basically, I only want to display 'Dummy 5' and not the images in the sub nav.
What's best practice for doing this?
The problem I see is that my gallery landing page could have any page type hanging off of it, so I could add a 'Show in sub nav' custom field, but that would require me to add that property to every data type, or I could filter my razor script to only show the data types I'm interested in, but that could end up being a massive list.
My script is:
<ulclass="nav clearfix"> @foreach (var level in @Model.AncestorsOrSelf(2).Where("Visible")) { if (@level.Level == 2) { foreach (var item in @level.Children.Where("Visible")) { <li><aclass="@{if(@Model.Url == @item.Url){@Html.Raw("selected");}}"href="@item.Url">@item.Name</a></li> } } } </ul>
I don't think he's looking for the first item. He's looking to filter the results. I know of no other "magic" way to filter those results than by adding a property to the Document Type or using the NodeTypeAlias.
"I don't think he's looking for the first item. He's looking to filter the results. I know of no other "magic" way to filter those results than by adding a property to the Document Type or using the NodeTypeAlias."
I've thought that you could just declare some property for the document types you need to show without asigning it any value and filter you content with HasProperty() method.
Subnav - only display certain page types
Ok so I have a gallery landing page with photos and video items and regular pages on the same branch:
http://screencast.com/t/ZrV7rXqS
And a sub nav on the gallery landing page:
http://screencast.com/t/jlDKAVGu
Basically, I only want to display 'Dummy 5' and not the images in the sub nav.
What's best practice for doing this?
The problem I see is that my gallery landing page could have any page type hanging off of it, so I could add a 'Show in sub nav' custom field, but that would require me to add that property to every data type, or I could filter my razor script to only show the data types I'm interested in, but that could end up being a massive list.
My script is:
Try something like this:
Or you might be able to do something like this:
Of course you'd have to replace Folder with the actual document type.
Dummy 5 is actually not a folder, it's a 'page' of content of a particular data type.
Yeah, you'd have to substitude "Folder" with the actual document type alias.
As in this?
http://screencast.com/t/dLVY5Bccmrq
The problem here is that I have many types... Seems cumbersome to list every individual type that should or should not appear on the nav.
If you in fact need only the first child item you can select it with:
I don't think he's looking for the first item. He's looking to filter the results. I know of no other "magic" way to filter those results than by adding a property to the Document Type or using the NodeTypeAlias.
Hmm. Well that won't work either:
http://screencast.com/t/YxOIaR4qtL
Dummy and Another Page need to show, but nothing else should.
My Sub Nav is in the master page, so I guess the only way around this is to add:
.Where("NodeTypeAlias" != "Gallery Item").Where("NodeTypeAlias" != "Promotion Item")
etc
Is that the only way to do it? No internal way of determining a data type is a stranged piece of content, or an actual page?
"I don't think he's looking for the first item. He's looking to filter the results. I know of no other "magic" way to filter those results than by adding a property to the Document Type or using the NodeTypeAlias."
Yup. That's what I thought.
@foreach (var level in @Model.AncestorsOrSelf(2).Where("Visible"))
{
if (@level.Level == 2)
{
foreach (var item in @level.Children.Where("Visible").Where("NodeTypeAlias" != "GalleryMediaItem"))
{
<li><aclass="@{if(@Model.Url == @item.Url){@Html.Raw("selected");}}"href="@item.Url">@item.Name</a></li>
}
}
}
Doesn't seem to work...
I've thought that you could just declare some property for the document types you need to show without asigning it any value and filter you content with HasProperty() method.
.Where("NodeTypeAlias" != "GalleryMediaItem"))
Will do the job if I knew the syntax!
Careful with the syntax. Refer to Umbraco Razor Feature Walkthrough – Part 4 for the correct syntax. Should be:
Got it thanks!
You can also use the parameterized syntax:
(Personally I prefer it so that not to mess about with backslashes)
Sweet cheers.
That's pretty neat. I didn't know about the parameterized syntax.
is working on a reply...