I am trying to create a dropdown in Umbraco 7, using the query builder. The dropdown is part of a navbar, which contains links to other pages as well. The page contains HTML with Razor code.
I tried nesting another query builder with the content I need for the dropdown into my navbar query builder and iterating through that
But this still doesn't create the dropdown. Instead it just returns a static link, where the dropdown should be shown. In my HTML prototype, the dropdown works fine using this code.
Why would nodes have the same name in the first child "Sprog". Wouldn't there only me one item with the same name since this is unique based on its container?
Are you trying to loop through all pages with DocType == "Sprog"? If this is the case maybe you want something like this...
var selection = Model.Content.Site().DescendantsOrSelf("Sprog").Where(x => x.IsVisible());
Again I am trying to understanding what you are trying to do here
var selection2 = Umbraco.TypedContent(1090).Children()
.Where(x => x.IsVisible());
Why are you looping through items in selecting and generating a list of items from TypedContent(1090). This code will return values but it will mean that each item in selection will have the same children.
Did you debug and inspect firstly selection to see if it contains items. If this is true then I guess you need to inspect selection2 and see if that contains any items.
I am guessing your queries are not doing what you expect???
If it helps here is a very simply dropdown navigation I have put together.
Thanks for taking the time to answer, and sorry for the confusing explanation.
I am looping through all the child content nodes og "Sprog", to display links to those pages in my navbar, which currently looks like this: http://i.imgur.com/477VkxK.png
What i want, is to have "Sommerhuse" as a dropdown, containing links to all the child content nodes of "Sommerhuse".
There is no "Sommerhuse" DocType. My tree structure for the DocTypes might looks a bit strange since I am using an XML package, which auto-generated most of them.
Displaying dropdown of links with query builder
I am trying to create a dropdown in Umbraco 7, using the query builder. The dropdown is part of a navbar, which contains links to other pages as well. The page contains HTML with Razor code.
I tried nesting another query builder with the content I need for the dropdown into my navbar query builder and iterating through that
But this still doesn't create the dropdown. Instead it just returns a static link, where the dropdown should be shown. In my HTML prototype, the dropdown works fine using this code.
Apologies for the bad formatting, for some reason Visual Studio refuses to auto-format .cshtml files.
Hi Thomas,
I am not 100% what you are trying to do but.....
Why would nodes have the same name in the first child "Sprog". Wouldn't there only me one item with the same name since this is unique based on its container?
Are you trying to loop through all pages with DocType == "Sprog"? If this is the case maybe you want something like this...
Again I am trying to understanding what you are trying to do here
Why are you looping through items in selecting and generating a list of items from TypedContent(1090). This code will return values but it will mean that each item in selection will have the same children.
Did you debug and inspect firstly selection to see if it contains items. If this is true then I guess you need to inspect selection2 and see if that contains any items.
I am guessing your queries are not doing what you expect???
If it helps here is a very simply dropdown navigation I have put together.
Hope this helps.
Kind Regards
David
Hi David
Thanks for taking the time to answer, and sorry for the confusing explanation.
I am looping through all the child content nodes og "Sprog", to display links to those pages in my navbar, which currently looks like this: http://i.imgur.com/477VkxK.png
What i want, is to have "Sommerhuse" as a dropdown, containing links to all the child content nodes of "Sommerhuse".
My content tree is structured like this: http://i.imgur.com/bVaAn4D.png
I'm trying to create a dropdown that contains all the items under "Sommerhuse".
For this I thought I needed to have 2 query builders, one for the content nodes under "DK" and one for the content nodes under "Sommerhuse"
I hope that cleared up some of the confusion.
I'll have a look at the dropdown navigation you sent.
And just to understand the tree structure. Does it look like something like this?
There is no "Sommerhuse" DocType. My tree structure for the DocTypes might looks a bit strange since I am using an XML package, which auto-generated most of them.
http://i.imgur.com/R0WvWwX.png
The children of "Sommerhuse" uses a "Sommerhus" DocType.
These are my queries that i built using the backoffice query builder:
http://i.imgur.com/OGcmjKg.png
http://i.imgur.com/hvbaGpM.png
"DK" has the DocType of "Sprog".
Try this...
if you don't care about the DocType and want to return all the children try this.
is working on a reply...