You might need to tell it which level of decendants you want it to return. Something like this maybe so it looks through the sub pages and then loops through any children of those sub pages:
<dl id="accordion">
@foreach(var item in feed.DescendantsOrSelf("SubPage").Where("level == 2")){
Razor - For each loop
I am trying to show a list of accordions on a page that im doing in umbraco
The setup is something like
But with the code above its just listing them out in one big accordion
What im trying to do is list them out in seperate accordions for each 'sub page' if this is possible?
Hi adam,
You might need to tell it which level of decendants you want it to return. Something like this maybe so it looks through the sub pages and then loops through any children of those sub pages:
Hey Ian
thanks a lot for the reply I couldnt get the above to work (it didnt render anything out)
Im not sure if the above would list them out in seperate accordions for example
at the moment it lists them out like:
<dl id="accordion">
<dt>sub sub page 1 stuff</dt>
<dt>sub sub page 2 stuff</dt>
</dl>
Im trying to list each sub page's content in its own accordion for example:
<dl id="accordion">
<dt>sub sub page 1 stuff</dt>
<dt>sub sub page 1 stuff</dt>
</dl>
<dl id="accordion">
<dt>sub sub page 2 stuff</dt>
</dl>
If the <dl id="accordion"> needs to be repeated you'll definitely need to have it inside of a foreach loop:
Also, you might want to give the <dl> a class of accordion rather than an ID as the ID won't be unique if there are more than one of them.
Hey thanks for the reply, but would this not just list every item out in a dl with a single dt?
Rather than spliting each sub page into a dl with its multiple dt's
It's tricky without knowing the structure of your pages in the content tree but how about something like this:
Is there a method to formatting code correctly in these forums - I can't seem to get it right - especially indenting lines!?
Thanks a lot Ian!! It works & thats exactly what I was trying to do :D
Awesome, glad you got it working!
is working on a reply...