Developer forum

Forum » CMS - Standard features » Is it possible to get url and title of page before and page after in pageview?

Is it possible to get url and title of page before and page after in pageview?

Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi

we have a task where we on the bottom of every page, want to link to the next page in the tree, and the previous page in the tree. The pages will not only on the same level, so eg. on a page - we will link to the before page in the tree (that is a parent) and the next page in the tree (sibling or child, or parent sibling)

Can this be done in a razor page template, or would I have to involve the infamous XSLT and do som queries inside XSLT?

BR.

Hans


Replies

 
Nicolai Pedersen
Reply

Hi Hans

You can do that in Razor.

Get a page using the pageservice. Every page has a parent id - you can use that. The page service has a GetPageNavigationTree that will give you a tree structure to iterate through.

BR Nicolai

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi Nicolai

thanx for the fast respons. I assume you mean this? http://doc.dynamicweb.com/Default.aspx?ID=8258#article=5de1e8ce-f046-f89c-8ad2-661d820fe87c

I am not used to working with this services. Is there any documentation on how to access/use them using razor, or can you give me some tip or an example?

thanx in advance.

 

BR

Hans

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Again looking into this (code below). This is probably some distance from how it should be, but can anybody guide me towards the right direction

 

Again, I would really really appreciate it :)

 

@{

 int parentpage = GetInteger("DwPageID_1");
 
 if (!string.IsNullOrEmpty(@GetString("DwPageID_1")))
    {

 var mytree = Dynamicweb.Content.IPageService.GetPageNavigationTree(parentpage);
        
if (mytree != null)
        {
            var treeName = mytree.PageIds;
          
        }
       
    }

   
}

 

 

 

 

You must be logged in to post in the forum