November Happy Hour will be moved to Thursday December 5th.

Calling a custom content provider from a page/controller

Vote:
 

Hello,

We have implemented a custom content provider with load, search and listing parameters. We mainly use it with a custom widget to get images and videos from an external API into a page. So far so good.

My question is - how can I use the content provider from a custom Page? Let's say I'd want to do something like searching the content provider for a certain query and always displaying the latest result, or hard-core an external content ID to display on a page.

Would I use the content provider directly in a page's controller, and/or do some config and registration to make that sort of thing work?

The content provider has the following interface:

public class MyCustomProvider : EPiServer.Core.ContentProvider
{
    public static string Key = "custom_provider";

    //...

    // ICustomMedia implements IContent
    public IEnumerable<ICustomMedia> Search(string query)
    {
        //...
    }

    protected override IContent LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
    {
        //...
    }

    protected override IList<GetChildrenReferenceResult> LoadChildrenReferencesAndTypes(
        ContentReference contentLink, string languageID, out bool languageSpecific)
    {
       //...
    }
    
    // ..
}
#302395
May 26, 2023 6:47
Vote:
 

Hi,

You can perform a multisearch that will search either a specific content provider or across all content providers.

If you check out the documentation this should point you in the right direction.

Paul

#302399
May 26, 2023 8:26
* 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.