Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Get all pages where a block is on

Vote:
 

Hi community,

I'm using EPiServer search and when I'm searhing for content that is on a block I can see that the search finds it. Now I want to get all pages this block is on so that I can return the result with a proper link to the page. I've heard there's an API for this but after looking for a while I can't find it. So the question, how do I get all pages this specific block is on?

Thanks!

#77950
Nov 29, 2013 7:48
Vote:
 

Hi Andreas,

At server side you can use: IContentRepository.GetReferencesToContent

At client side you can:

this.store = this.store || dependency.resolve("epi.storeregistry").get("epi.cms.contentreferences");
when(this.store.refresh(/*your block id*/this.blockId), lang.hitch(this, function (data) {
    var pageReferences = [];
    array.forEach(data, function (item) {
        if (item && item.isPage) {
            pageReferences.push(item);
        }
    });
}));

    

Note: We already have a helper class to do this: sharedContentDialogHandler

BR

Ha Bui

#77953
Edited, Nov 29, 2013 8:22
Vote:
 

Perfect, Just one more question that isn't 100% related to this. When I get my search result back from the indexing I get some properties. One is called ID and looks like this 

b7c6d596-5719-4b12-84ea-72084c688caf|sv

In the database I see there is a ContentGUID for b7c6d596-5719-4b12-84ea-72084c688caf so I thought that I could do 

var cR = new ContentReference("b7c6d596-5719-4b12-84ea-72084c688caf");

But it gives me an exception, Do you know any way of gettign a ContentReference without using FindPagesWithCriteria (which I don't know if it searches on blocks as well actually)...
Thanks!

#77962
Nov 29, 2013 10:03
Vote:
 

Hi Andreas,

You don't need do that. Actually, you can get IContent directly with ContentGUID with: Get<T>(Guid contentGuid)

BR

Ha Bui

#77963
Nov 29, 2013 10:10
Vote:
 

Thanks!

#77966
Nov 29, 2013 10:23
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.