November Happy Hour will be moved to Thursday December 5th.

Get all References of a particular page

Vote:
 

Hi,

I have created a page Named ExternalPage in Episerver using MVC. I want to get all the references of that paticular page and its Properties created by the user. Can anyone help me out how to get the references of the pages.

public class ExternalController : PageControllerBase

#145830
Mar 14, 2016 8:37
Vote:
 

Hi!

If i get you right you should be able to get children or get descending from your website root or startpage like this.

var pages = contentLoader.GetChildren<ExternalPage>(pageReference);

where pageReference is either startpage or your website root.

Then just loop through your collection or pages and access the properties.

NOTICE, GetChildren will only return the first level of the page tree.


Have a nice day.

#145842
Mar 14, 2016 10:56
Vote:
 

If you mean references like incoming links or where that page is used as a page reference you can use

repository = ServiceLocator.Current.GetInstance<IContentRepository>();
var references = repository.GetReferencesToContent(content.ContentLink, true).ToList();
Dejan tried to handle some weird cases as well
Hi Dejan again btw :)
#145844
Edited, Mar 14, 2016 11:20
Vote:
 

Thanks  Robin i am able to find the solution now.

#145897
Mar 15, 2016 7:39
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.