I'm working on a site that has a page structure similar to that below:
- Home - Contracts -- Commercial --- Commercial Sub Page 1 --- Commercial Sub Page 2 -- Private --- Sub Page 1 --- Sub Page 2
(etc)
The pages all have a standard template, but I'm wondering how I could use Razor to display all pages within a section. Say If I was on 'Commercial Sub Page 1' how could I show a list of other pages in the commercial section on the page?
Are you saying you've got a single documen type or am I misreading thsi?
It would be much nicer to go up to up to the parent "SectionDocType" - e.g. CurrentPage.AncestorOrSelf("SectionTypeAlias") but this should work via level:
If you have to include this on all pages then you'll need to check what level you're on I guess (included - I've guessed level two).
@{
if(CurrentPage.Level > 2) {
var section = CurrentPage.AncestorOrSelf(2);
if (section != null)
{
var childItems = section.Children;
foreach (var page in childItems)
{
<p>@page.Name</p>
}
}
}
}
Show pages within section
Hey,
I'm working on a site that has a page structure similar to that below:
- Home
- Contracts
-- Commercial
--- Commercial Sub Page 1
--- Commercial Sub Page 2
-- Private
--- Sub Page 1
--- Sub Page 2
(etc)
The pages all have a standard template, but I'm wondering how I could use Razor to display all pages within a section. Say If I was on 'Commercial Sub Page 1' how could I show a list of other pages in the commercial section on the page?
I'm using Umbraco 7
Many thanks!
Are you saying you've got a single documen type or am I misreading thsi?
It would be much nicer to go up to up to the parent "SectionDocType" - e.g. CurrentPage.AncestorOrSelf("SectionTypeAlias") but this should work via level:
If you have to include this on all pages then you'll need to check what level you're on I guess (included - I've guessed level two).
is working on a reply...