Use Piranha CMS Manager editor in application for other users

  Kiến thức lập trình

I am trying to create some dynamic forms using Piranha CMS. As far as I managed to learn it is not supported right now, so I’m looking for work arounds or alternatives.

What I want to do now is use the editor from the manager for other users. To be more precise: this is how the editor looks like inside my manager when I want to edit a page
enter image description here
I have a text input and a select, both are Fields and there are many more fields to be used.

I want the sys admin to create a page with a list of inputs like this, which right now are usable only by the admin. BUT make this list of inputs available for edit to other users as well. Is it possible?

I’m not sure how to extract this editor or behavior or even if it is possible. The problem is we really need the admin to be able to configure different form inputs for users as it is the main core of our functionality.

Any help/advice is highly appreciated, thank you!

2

The components in the management UI is not designed to be reused in the front-end application in any way. The edit models in the manager contains a lot of extra meta data since the UI is completely generic. If you want to build an edit UI in your front end application, and you’re using MVC or Razor Pages, the simplest way is to.

  1. Get the generic model instead of your strongly typed model, for example api.Pages.GetById(...) instead of api.Pages.GetById<T>(...).
  2. Loop the available fields in your selected region (a region is an ExpandObject which can be casted to an IDictionary<string, object>).
  3. Use the built in support in Razor by calling @Html.EditorFor(...) for the fields.

Using this approach you can easily create your own EditorTemplates for the different types of fields you use that will match the rendering in your client application.

Best regards

Håkan

LEAVE A COMMENT