My question is related to this one , but instead of changing the question, I thought it would be better to ask a new one.
Now I have a list of IContent elements using _taxonomyService.GetContentItems (term)
as @ Bertrand Le Roy suggested in the above question
But how can I turn this into a useful Html line that I can update on the client via ajax post?
public class HomeController : Controller { private readonly IOrchardServices _services; private readonly IBlogService _blogService; private readonly IBlogPostService _blogPostService; private readonly IFeedManager _feedManager; private readonly IArchiveConstraint _archiveConstraint; private readonly ITaxonomyService _taxonomyService; public HomeController( IOrchardServices services, IBlogService blogService, IBlogPostService blogPostService, IFeedManager feedManager, IShapeFactory shapeFactory, IArchiveConstraint archiveConstraint, ITaxonomyService taxonomyService) { _services = services; _blogService = blogService; _blogPostService = blogPostService; _feedManager = feedManager; _archiveConstraint = archiveConstraint; T = NullLocalizer.Instance; Shape = shapeFactory; _taxonomyService = taxonomyService; } dynamic Shape { get; set; } public Localizer T { get; set; } public ActionResult Index() { return View(); } [HttpPost] public JsonResult ListByArchive(string path, IEnumerable<string> category) { try {
....
This gets my IContent list, but how do I get the html for the displayed list?
I tried
var range = byDate.Select(x => _services.ContentManager.BuildDisplay(x, "Summary")); var list = Shape.List(); list.AddRange(range); dynamic viewModel = Shape.ViewModel().ContentItems(list); var html = View((object)viewModel); return Json(new { html = html });
but it returns an empty view,
{"html":{"MasterName":"","Model":[],"TempData":[],"View":null,"ViewBag":{},"ViewData":[],"ViewEngineCollection":[{"HostContainer":{}}],"ViewName":""}}
I have a view called ListByArchive.cshtml that matches the orchard.blog module.
As an aside, I should return the result of the partial view, not the result of jason, but when I change the type of the result of Action, I get the result of 404. From the server.