PageController with multiple Views - inline editable?

Vote:
 

When a single PageController has multiple methods that return different Views, these views does not seem previewable in preview mode in the CMS system, when clicking an actionlink to the view in edit mode I am returned to the Index page. The content is not inline editable.

So e.g. if I have a class:

class EntityController : PageController {

  ActionMethod Index(){... return View("~/Views/Entity/Index.cshtml")}

  ActionMethod Edit(Guid id){... return View("~/Views/Entity/Edit.cshtml")}

  ActionMethod Create(){... return View("~/Views/Entity/Create.cshtml")}

}

And in the Index.cshtml view:

@Html.ActionLink("Edit", "Edit", new { id = row.Id })

This works fine in the non edit mode, but clicking the button in edit mode does not load the Edit page but returns to the index page and the content is not inline editable.

How do you deal with this? Do I really hav to make PageTypes and PageControllers for each view?

#191902
Edited, May 02, 2018 14:42
Vote:
 

My guess is you have to manually add custom page edit routes to RouteCollection. The default page edit route looks like this:

routes.MapEditRoutes(
    "editpageroot",
    RouteCollectionExtensions.CmsHomePath + "{language}/{nodeedit}/{partial}/{action}", 
    new
    {
        action = "index"
    }, 
    null
);

RouteCollectionExtensions.CmsHomePath is unfortunately private and contains this:

private static string CmsHomePath
{
  get
  {
    return VirtualPathResolver.Instance.ToAppRelative(VirtualPathUtility.AppendTrailingSlash(ModuleResourceResolver.Instance.ResolvePath("CMS", "Content"))).Substring(1);
  }
}
#191912
May 02, 2018 16:27
Vote:
 

Yes you need a PageType or BlockType for it to be manageble in the CMS. 

#191924
May 02, 2018 19:57
Vote:
 

Thanks for the responses. Maybe I can reuse the same controller class for multiple Page/Blocktypes?

#191932
May 03, 2018 8:28
Vote:
 

theoretically you can if contnet types are "compatible". look for TemplateDescriptors keyword in documentation.

#191977
May 03, 2018 12:13
Vote:
 

Thanks. I ended up just creating a page for each controller. With a baseclass for shared properties.

#192120
May 08, 2018 6:52
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.