Copied to clipboard

Flag this post as spam?

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


  • navid 9 posts 88 karma points
    Apr 18, 2017 @ 12:43
    navid
    0

    how to add my strongly type models to my project?

    I want to pass models to my PartialView and for this goal i must inherit my partial view from:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage

    but i donot know where must i add this model. how can i create this model? is there any tool in backoffice or is there any spatial folder for inserting my models inside it?

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Apr 18, 2017 @ 12:46
    Alex Skrypnyk
    1

    Hi Navid

    First of all you have to add another inherits:

    @inherits UmbracoViewPage<YourModelClassName>
    

    Where YourModelClassName - is your document type class name.

    Umbraco Models builder creates class for each document type. Read docs here: https://github.com/zpqrtbnk/Zbu.ModelsBuilder/wiki/Umbraco.ModelsBuilder

    What version of Umbraco are you using?

    Thanks,

    Alex

  • navid 9 posts 88 karma points
    Apr 19, 2017 @ 05:23
    navid
    0

    I am using umbraco v 7.5.13. about generic inheritance you are right. i forget to add this part of code

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Apr 19, 2017 @ 05:54
    Dave Woestenborghs
    0

    Hi Navid,

    I wrote an article once about the difference in stronly typed and dynamic content access in Umbraco. It also explains the difference between the different template base types.

    http://24days.in/umbraco-cms/2015/strongly-typed-vs-dynamic-content-access/

    And if you are interested in generating strongly typed models from your doctypes this article I wrote is also interesting. It explains the different modes you can use the Umbraco Modelsbuilder in : http://24days.in/umbraco-cms/2016/getting-started-with-modelsbuilder/

    Dave

  • navid 9 posts 88 karma points
    Apr 19, 2017 @ 07:16
    navid
    0

    I create some data type by using archetype package in my solution. now i want create my model base on this datatypes and use them as model type in my partial view. is there any solution in modelsBuilder to build this models from datatype???

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Apr 19, 2017 @ 07:21
    Dave Woestenborghs
    0

    Hi Navid,

    I haven't used Archetype lately. But it's well documented : https://github.com/kgiszewski/ArchetypeManual

    Maybe this can help you figure out how to work with strongly typed models in combination with archetype.

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft