Find the pages using my page
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
Mar 25, 2008 18:36
-
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?
-
Here you go:
using EPiServer;
using EPiServer.Core;
...
PageReferenceCollection links =
DataFactory.Instance.GetLinksToPages(new PageReference(4)); -