Find all pages where shared block is added

Mats Knutsen-Valen
Member since: 2010
 

Hi,

given a ContentLink on a Block, how do I find all pages where this block is added? It is a shared block.

 

#65056 Jan 18, 2013 12:42
  • Mats Knutsen-Valen
    Member since: 2010
     

    Solved it like this(With episerver.find):

    var i = SearchClient.Instance.Search<MyBlock>()
    .For(searchQuery)
    .GetContentResult();

    foreach(var p in i){
    var y = p as IContent;
    var z = ServiceLocator.Current.GetInstance<IContentRepository>();
    var z1 = z.GetReferencesToContent(y.ContentLink, false);

    //dosomething

    }

    #65058 Jan 18, 2013 13:02