Files
Umbraco-CMS/src/Umbraco.Web/Routing/LookupByPageIdQuery.cs
Shannon Deminick 73c79e8528 After talks with morten and stephane, this renames
IDocumentLookup -> IPublishedContentLookup
2012-10-02 01:43:05 +05:00

30 lines
886 B
C#

namespace Umbraco.Web.Routing
{
/// <summary>
/// This looks up a document by checking for the umbPageId of a request/query string
/// </summary>
/// <remarks>
/// This is used by library.RenderTemplate and also some of the macro rendering functionality like in
/// insertMacro.aspx and macroResultWrapper.aspx
/// </remarks>
internal class LookupByPageIdQuery : IPublishedContentLookup
{
public bool TrySetDocument(PublishedContentRequest docRequest)
{
int pageId;
if (int.TryParse(docRequest.RoutingContext.UmbracoContext.HttpContext.Request["umbPageID"], out pageId))
{
var doc = docRequest.RoutingContext.PublishedContentStore.GetDocumentById(
docRequest.RoutingContext.UmbracoContext,
pageId);
if (doc != null)
{
docRequest.PublishedContent = doc;
return true;
}
}
return false;
}
}
}