var eventOverview = Umbraco.AssignedContentItem.AncestorOrSelf("eventOverviewDocTypeAlias");
And then
IEnumerable<IPublishedContent> children = parent.Children;
To (updating the doc type alias to match yours)
var children = eventOverview.DescendantsOfType("eventItemDocTypeAlias");
NOTE: you will have to change "eventOverviewDocTypeAlias" and "eventItemDocTypeAlias" to be the doc type aliases that match yours - this is the event landing page and the one for the individual the event items. You can get this from the Info tab, over over the text under "Document Type". It will usually be in camelCase, this is important.
Since I have only one document type of items to user it for that is structured in categories (the others are child nodes of the index page) I have changed the code to be generic for my setup:
IPublishedContent root = null;
if(Model.ContentType.Alias == "uge30_activity")
{
root = Umbraco.AssignedContentItem.AncestorOrSelf("uge30_activities_index");
} else {
root = Umbraco.AssignedContentItem.Parent;
}
var children = root.DescendantsOfType(Model.ContentType.Alias);
List<int> childrenIds = children.Select(x => x.Id).ToList();
int currentIndex = childrenIds.IndexOf(Umbraco.AssignedContentItem.Id);
IPublishedContent prev = null;
IPublishedContent next = null;
if (currentIndex > 0)
{
prev = children.ElementAt(currentIndex - 1);
}
if (currentIndex < (children.Count() - 1))
{
next = children.ElementAt(currentIndex + 1);
}
The "uge30_activity" is the only one not directly put under the overview pages.
Previous and next links for nodes in a category structure
Hi,
I have a FAQ section with this structure:
For this I have this working code on the FAQ item template that creates next and prev links:
But for this strucure I need to tweak the code. Any hints?
Hi,
You should be able to use similar logic.
I'm assuming this is in a partial which is why you're using AssignedContentItem..
Change
To: (updating the doc type alias to match yours)
And then
To (updating the doc type alias to match yours)
NOTE: you will have to change "eventOverviewDocTypeAlias" and "eventItemDocTypeAlias" to be the doc type aliases that match yours - this is the event landing page and the one for the individual the event items. You can get this from the Info tab, over over the text under "Document Type". It will usually be in camelCase, this is important.
I hope this helps.
Steve
Great! Thank you. That did the trick.
Since I have only one document type of items to user it for that is structured in categories (the others are child nodes of the index page) I have changed the code to be generic for my setup:
The "uge30_activity" is the only one not directly put under the overview pages.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.