mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Adding AJAX-support to the content item controller, fixes #2703
This commit is contained in:
@@ -9,9 +9,14 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
[Themed]
|
||||
public class ItemController : Controller {
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IHttpContextAccessor _hca;
|
||||
|
||||
public ItemController(IContentManager contentManager, IShapeFactory shapeFactory, IOrchardServices services) {
|
||||
public ItemController(IContentManager contentManager,
|
||||
IShapeFactory shapeFactory,
|
||||
IOrchardServices services,
|
||||
IHttpContextAccessor hca) {
|
||||
_contentManager = contentManager;
|
||||
_hca = hca;
|
||||
Shape = shapeFactory;
|
||||
Services = services;
|
||||
T = NullLocalizer.Instance;
|
||||
@@ -39,6 +44,10 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
}
|
||||
|
||||
var model = _contentManager.BuildDisplay(contentItem);
|
||||
if (_hca.Current().Request.IsAjaxRequest()) {
|
||||
return new ShapePartialResult(this,model);
|
||||
}
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@@ -62,6 +71,10 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
}
|
||||
|
||||
var model = _contentManager.BuildDisplay(contentItem);
|
||||
if (_hca.Current().Request.IsAjaxRequest()) {
|
||||
return new ShapePartialResult(this, model);
|
||||
}
|
||||
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user