Try our conversational search powered by Generative AI!

Find the pages using my page

Vote:
 
Sometimes when you delete a page in EPiServer, it notifies you that the page is being used by another page (has a property with the page's reference as a value) and asks you if you are sure you want to delete it. Is there any way that I can make this search in my code, i.e. how can I find all the pages that has a reference to a certain page? /Erik
#13362
Feb 19, 2008 10:14
Vote:
 

I suggest looking at the Page Collection object such as \Templates\Public\Units\Static\MainMenu.ascx.cs and using each page from DataFactory.Instance, check certain properties (e.g. MainBody) for the value returned from  <EPiServer:Property ID="Property1" PropertyName="PageLink" runat="server" />

 

Obviously this is a bit general but something along these lines - although I KNOW this isn't the most effective piece of code - can someone else help out and suggest a better way?

 

 

#30035
May 27, 2009 15:47
Vote:
 

Here you go:

using EPiServer;
using EPiServer.Core;

...

PageReferenceCollection links =
DataFactory.Instance.GetLinksToPages(new PageReference(4));
#30042
May 27, 2009 21:11
Vote:
 

Thank you for that piece of code. Simple.  Beautiful.  Simply beautiful!

 

#30048
May 28, 2009 11:02
* 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.