Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ben Haynie 20 posts 50 karma points
    Dec 17, 2013 @ 02:16
    Ben Haynie
    0

    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?

    Thank you in advanced, Ben

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Dec 17, 2013 @ 09:17
    Jeavon Leopold
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft