Editors

Lynicon's editor system is a generic and adaptable way of providing editing of the data stored in the Data API. Essentially, a DataRoute processing a request uses an inheritor of EditorRedirect (chosen by the type of data being requested) to decide whether the request should be diverted to a special controller.  This controller (which will normally inherit from EditorController) creates a page with form elements which when posted back, are used to update the relevant content item via model binding.

Setting the Editor to use for a Route or Content Type

By default, DataRoute uses ContentEditorRedirect which redirects to DualFrameEditorController.  This supports the standard page editor.

You can change this behaviour per type or per DataRoute.  To change the EditorRedirect used for a DataRoute, do this:

regContext.Routes.AddDataRoute<List<Comment>>("comment-mod-list", "lynicon/comment-mod-list",
  new { controller = "Comment", action = "Moderate" },
  new WebEditorRedirect(User.EditorRole, User.EditorRole, User.EditorRole,
  cl => CommentManager.Instance.AddUrlToComments(CommentManager.Instance.HydrateComments((List<Comment>)cl)), null));

In this example, a data route is set up for lists of Comment type content. An instance of WebEditorRedirect is here passed in to the data route initialisation to control how diversion to the editor is managed just on this route.

To change the EditorRedirect used for a content type, do this:

EditorRedirect.Instance.Register(typeof(List<User>), new ListEditorRedirect(new List<string> { "UserName", "Email", "Created", "Modified", "Roles" }));

In this example any DataRoute<T> where T is List<User> will now use the instance of ListEditorRedirect provided to control how diversion to the editor is controlled.