In previous versions of Kentico (and still in KX13 if you want to use it) you'd use DocumentQuery to build up queries to retrieve pages.
IPageRetriever is essentially a wrapper around DocumentQuery - it lets you retrieve pages but makes it easier by automatically ensuring you're retrieving the right version with the current site and current culture. Example taken from here.
private readonly IPageRetriever pageRetriever;
// Gets an instance of the IPageRetriever service using dependency injection
public ExampleController(IPageRetriever pageRetriever)
{
this.pageRetriever = pageRetriever;
}
public ActionResult Index()
{
// Retrieves pages of the 'Article' page type that are in the '/Articles/May' section of the content tree
var articles = pageRetriever.Retrieve<Article>( documentQuery => documentQuery
.Path("/Articles/May", PathTypeEnum.Children));
// Retrieves pages of a custom 'Landing page' page type from the '/Landing-pages/Products' section of the content tree
var landingPages = pageRetriever.Retrieve("Custom.LandingPage"( documentQuery => documentQuery
.Path"/Landing-pages/Products", PathTypeEnum.Children));
// Retrieves pages of multiple page types from the '/Archive' section of the content tree
var pages = pageRetriever.RetrieveMultiple( multiDocumentQuery => multiDocumentQuery
.Path("/Archive", PathTypeEnum.Children));
}
IPageDataContextRetriever is used within Controllers/ViewComponents to access the currently requested page. Example taken from here.
private readonly IPageDataContextRetriever dataRetriever;
public ArticlesController(IPageDataContextRetriever dataRetriever)
{
// Initializes an instance of a service that provides data context of pages matching the requested URL
this.dataRetriever = dataRetriever;
}
public ActionResult Show()
{
...
// Gets the page of the Article page type matching the currently requested URL
var article = dataRetriever.Retrieve<Article>().Page;
...
}