4

I'm wondering if there is some API/Code/Trick on Sitecore to fetch all linked/related Items to a given Sitecore item, just like we have on the XP Admin interface?

My goal here is to find all pages using a given item as a data source of one of its renderings.

enter image description here

2
  • 2
    Something like Sitecore.Globals.LinkDatabase.GetReferrers({current item}) or I missed the point of your question?
    – Marek Musielak
    Aug 15, 2019 at 18:43
  • Actually, that's exactly what I was looking for, thanks Marek :) Aug 15, 2019 at 19:03

2 Answers 2

4

You can use from code: ItemLink[] itemLinks = Globals.LinkDatabase.GetReferrers(item);

Or from Content Editor you can use Link ribbon button from Navigate tab:

enter image description here

2

You can use Link Database via GetReferrers method. e.g.

var links = Globals.LinkDatabase.GetReferrers(item);
  if (links == null)
    return new Item[0];
  var linkedItems = links.Select(i => i.GetSourceItem()).Where(i => i != null);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.