Locate.ContentLoader() when using Episerver search

Vote:
 

Hi,

im looking at the Search example at the SDK developer guide : http://sdkbeta.episerver.com/SDK-html-Container/?path=/SdkDocuments/CMS/7/Knowledge%20Base/Developer%20Guide/Search/FullTextSearchCMSIntegration.htm&vppRoot=/SdkDocuments//CMS/7/Knowledge%20Base/Developer%20Guide/

When I am doing a copy/paste of the sample code for searching pages I get error on all the lines with Locate.<something> . I googled and found some code using : 

var context = new InitializationEngine();

context.Locate.ContentLoader() 

this does however give me an object reference is null error.

What am I doing wrong ? 

#64302
Dec 17, 2012 14:14
Vote:
 

The code I found is from this link: 

http://sdkbeta.episerver.com/SDK-html-Container/?path=/SdkDocuments/CMS/7/Knowledge%20Base/Developer%20Guide/Partial%20Routing/News%20partial%20routing%20example.htm&vppRoot=/SdkDocuments//CMS/7/Knowledge%20Base/Developer%20Guide/#Controller

 

public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context)
    {
        var startPage = context.Locate.ContentLoader().Get<PageData>(PageReference.StartPage);

        //There should be a property on start page that sets the newsContainer page.
        var partialRouter = new NewsPartialRouter(new NewsContentStore(), startPage["NewsContainer"] as ContentReference);
        RouteTable.Routes.RegisterPartialRouter<NewsContainer, NewsContent>(partialRouter);

        NewsContentGenerator.CreateFakeData();
    }
 
#64312
Dec 17, 2012 15:40
Vote:
 

Solved it by fetching the ServiceLocationHelper :

 var serviceLocationHelper = ServiceLocator.Current.GetInstance<ServiceLocationHelper>();

 serviceLocationHelper.ContentLoader()

#64325
Dec 18, 2012 9:22
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.