Create Editable Partial Views for an Umbraco Plugin
Hello, I have a bit of an odd question. I would like to work on an Umbraco Plugin that would allow the client to modify the Partial Views that I use.
For example, I would create the following model:
public class PersonModel
{
public int PersonID { get; set; }
public int FirstName { get; set; }
public int LastName { get; set; }
}
and I would create a Controller that would look something like this:
public class PersonSurfaceController: Umbraco.Web.Mvc.PluginController
{
public ActionResult GetPerson()
{
PersonModel model = new PersonModel{PersonID=1,FirstName="Me",LastName="Myself"};
return PartialView(model);
}
[HttpPost]
public ActionResult GetPerson(PersonModel model)
{
//Save here
return PartialView(model);
}
}
Finally, I would like to create the View. This is the kicker. I would like to make it so that the view can be modified by an Umbraco Administrator. So that if they want to be able to change the layout, the colors, etc, they can do that. I.E. some clients may want to have the person laid out horizontally, some might want to have it laid out vertically.
I would love to make it so that we could even dynamically change the View, so they could create a whole new view and use that. This way, if they get an update to the plug in it doesn't automatically overwrite any changes them may have made to the view.
I thought I might be able to use Partial View Macro's. However, it seems that if I do this I can't call it from the Controller (I don't know the name, and I can't pass Models to the Partial View Controller).
And if I just use Partial Views, I am not sure if there is an interface from the Umbraco Back Office to be able to modify the Partial Views.
Is there something that I can do to help meet my objectives? Allow the Umbraco Administrator to modify the Partial Views from the Back Office, and also allow them to come up with custom views?
Within the settings section you should have a partial views tree which will show all partials in the /Views/Partials folder and allow you to edit and add new ones directly in the UI.
Create Editable Partial Views for an Umbraco Plugin
Hello, I have a bit of an odd question. I would like to work on an Umbraco Plugin that would allow the client to modify the Partial Views that I use.
For example, I would create the following model:
and I would create a Controller that would look something like this:
Finally, I would like to create the View. This is the kicker. I would like to make it so that the view can be modified by an Umbraco Administrator. So that if they want to be able to change the layout, the colors, etc, they can do that. I.E. some clients may want to have the person laid out horizontally, some might want to have it laid out vertically.
I would love to make it so that we could even dynamically change the View, so they could create a whole new view and use that. This way, if they get an update to the plug in it doesn't automatically overwrite any changes them may have made to the view.
I thought I might be able to use Partial View Macro's. However, it seems that if I do this I can't call it from the Controller (I don't know the name, and I can't pass Models to the Partial View Controller).
And if I just use Partial Views, I am not sure if there is an interface from the Umbraco Back Office to be able to modify the Partial Views.
Is there something that I can do to help meet my objectives? Allow the Umbraco Administrator to modify the Partial Views from the Back Office, and also allow them to come up with custom views?
Thank you in advanced, Ben
Hi Ben,
Within the settings section you should have a partial views tree which will show all partials in the /Views/Partials folder and allow you to edit and add new ones directly in the UI.
Jeavon
is working on a reply...