Copied to clipboard

Flag this post as spam?

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


  • Ion Cracea 12 posts 93 karma points
    Apr 01, 2020 @ 13:53
    Ion Cracea
    0

    The type or namespace name 'Test' does not exist in the namespace 'Umbraco.Web.PublishedModels'

    Hello, I'm using Umbraco 8 and Umbraco Model Builder v8.1.0. Since I've installed the Model Builder, every time I create content (page) I get the below error when visiting this page.

    The type or namespace name 'Test' does not exist in the namespace 'Umbraco.Web.PublishedModels' (are you missing an assembly reference?)
    

    EX: Document Type: "Test"

    Template:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.Test>
    @using ContentModels = Umbraco.Web.PublishedModels;
    @{
        Layout = null;
    }
    

    Content: "Test Page"

    And I get this error when visiting the page:

    The type or namespace name 'Test' does not exist in the namespace 'Umbraco.Web.PublishedModels' (are you missing an assembly reference?)
    

    Config file:

    <add key="Umbraco.ModelsBuilder.Enable" value="true" />
    <add key="Umbraco.ModelsBuilder.EnableApi" value="true" />
    <add key="Umbraco.ModelsBuilder.ModelsMode" value="Nothing" />
    

    Can anyone help? Thank you.

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Apr 01, 2020 @ 14:47
    Marc Goodson
    2

    Hi Ion

    this line here:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.Test>
    

    tells Umbraco that the view is going to use a custom model called 'Test' and this is automatically generated by Modelsbuilder.

    if you are not using ModelsBuilder then you can change this to be

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    

    and you can write out properties using the syntax

    @Model.Value("title")
    

    If you want to use 'ModelsBuilder' then whether you get this error or not will depend on where you are generating your models, and whether or not you have a Document Type called Test, and whether this is being generated correctly and in the ContentModels namespace... to somewhere...

    From your config it looks like you are using Api mode to generate the Models...

    There is some useful info on this page on how to setup ApiMode:

    https://github.com/zpqrtbnk/Zbu.ModelsBuilder/wiki/Builder-Modes

    regards

    Marc

  • Ion Cracea 12 posts 93 karma points
    Apr 01, 2020 @ 15:05
    Ion Cracea
    0

    Thank you for a great reply!

    I'm using API ModelBuilder

    adding the right namespace to the template solved the issue.

    @using Project.Models - this is where models are generated
    
    @inherits Umbraco.Web.Mvc.UmbracoViewPage<Test> - used this instead of <ContentModels.Test>
    

    Do you know, how do I display the model's properties? If I have a title property on the test document type, how do I display its value on the page?

    Thank you.

  • Ion Cracea 12 posts 93 karma points
    Apr 01, 2020 @ 15:18
    Ion Cracea
    0

    I've tried

    @Model.{propertyName}

    That returns:

    "EDITOR": { "NAME": "RICH TEXT EDITOR", "ALIAS": "RTE", "VIEW": "RTE", "RENDER": NULL, "ICON": "ICON-ARTICLE", "CONFIG": {} }, "STYLES": NULL, "CONFIG": NULL } ], "STYLES": NULL, "CONFIG": NULL } ], "STYLES": NULL, "CONFIG": NULL } ] } ] }
    

    How do I render this ?

  • Ion Cracea 12 posts 93 karma points
    Apr 01, 2020 @ 15:33
    Ion Cracea
    1

    Solved, the property is a grid layout, had to use: property alias is - "content"

    @Html.GetGridHtml(Model, "content")
    

    Thank you all for your help!

Please Sign in or register to post replies

Write your reply to:

Draft