Copied to clipboard

Flag this post as spam?

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


  • Nitin Anand 46 posts 178 karma points
    Nov 08, 2016 @ 10:55
    Nitin Anand
    0

    Is it possible to edit Models in Umazel starter kit?

    Hi, i like to develop further my umazel site. I like to know if i can add/delete/edit a property in a model class? I need to add a new property but i am not able to do that in c# code in model class. I can add new properties in document type from umbraco back office but then how can i show them/ implement them on view/.cshtml file?

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Nov 08, 2016 @ 17:23
    Alex Skrypnyk
    0

    Hi Nitin,

    Maybe you have to add new field in Umbraco doctypes before changing models?

    Thanks

    Alex

  • Nitin Anand 46 posts 178 karma points
    Nov 09, 2016 @ 07:59
    Nitin Anand
    0

    i did try adding property from umbraco backoffice, it did but i couldnt use that property. New property doesnt exist in c# code. The model classes shows a lock sign 'metadata'

  • Sotiris Filippidis 286 posts 1501 karma points
    Nov 08, 2016 @ 19:18
    Sotiris Filippidis
    0

    Hi Nitin,

    Models are currently created in DLL mode. So if you need to extend your models you may have to create/alter new doctypes/properties and either rebuild your models (from the "Developer" section) or switch to App_Data mode.

    I hope I understood correctly - otherwise, please let me know.

  • Nitin Anand 46 posts 178 karma points
    Nov 09, 2016 @ 12:46
    Nitin Anand
    0

    I can try to explain with an example. In my umbraco project's Umazel theme, i want to add a new property called 'Price' in a, for example, Document type ContentSliderItem so that i can show this property later in the respective view. I added the property in umbraco back office on the document type. Now back in c# code, i open the .cshtml view where i want my new property should be placed. But the view doesnt read the property because its not present in the viewmodel.

    When i try to add in viewmodel class i find i am not able to modify this class, it shows a lock-down icon with class and says [from metadata].

    let me know if i'm unclear

    thanks in advance

  • Sotiris Filippidis 286 posts 1501 karma points
    Nov 10, 2016 @ 08:28
    Sotiris Filippidis
    100

    Well, as I mentioned in my previous comment, when you add a new property you will have to rebuild your models - here's a short screencast where I'm adding a property with alias "blah" to the Text Section and show you what I do in Umbraco in order to make it work with Visual Studio: http://screencast-o-matic.com/watch/cDX6j0jPkc

  • Nitin Anand 46 posts 178 karma points
    Nov 10, 2016 @ 09:39
    Nitin Anand
    0

    perfect! Now i am able to add properties. I missed rebuilding using modelbuilder from back office. thanks for the valuable help

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies