Copied to clipboard

Flag this post as spam?

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


  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    May 03, 2021 @ 06:52
    Paul Seal
    0

    How do I get IPublishedContent intellisense to work in the views

    Hi I'm building a site in Umbraco 9 and I am struggling because I don't have the usual intellisense for IPublishedContent.

    Please can you tell me how I get intellisense to work.

    I want to be able to do @Model. and see the available properties etc

    Kind regards

    Paul

  • Bjarke Berg 29 posts 265 karma points hq
    May 03, 2021 @ 06:58
    Bjarke Berg
    0

    Hi Paul..

    What Models Builder mode are you running? If it is PureLive, it is not expected that you can see the properties from the model in the IDE.

    If you run AppData mode, you need to include the files in the project. And then you should have IntelliSense

    enter image description here

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    May 03, 2021 @ 08:52
    Paul Seal
    0

    Ok I will try that, thanks.

    How do I change the models builder mode with the appSettings.json?

  • Bjarke Berg 29 posts 265 karma points hq
    May 03, 2021 @ 08:58
  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    May 03, 2021 @ 10:20
    Paul Seal
    0

    Thanks but where are the files in the solution that I need to include please? It’s not obvious to me.

  • Bjarke Berg 29 posts 265 karma points hq
    May 03, 2021 @ 11:23
    Bjarke Berg
    0

    Sorry :)

    The default path is /umbraco/models But that can be changed on the in the settings too, using the key ModelsDirectory

    {
      "Umbraco": {
        "CMS": {
          "ModelsBuilder": {
            "ModelsMode": "AppData",
            "ModelsDirectory": "/whatever/path/"
          }
        }
      }
    }
    
  • Andrew 52 posts 234 karma points
    May 06, 2021 @ 17:10
    Andrew
    0

    I've been simply including the files in umbraco/models and setting them to compile. I saw this post and tried setting ModelsDirectory.

    I seem to get an error no matter what I put in ModelsDirectory.

    Even when I try "ModelsDirectory": "/umbraco/models/" or "ModelsDirectory": "/umbraco/models"

    ConfigurationException: Invalid models directory "/umbraco/models/".

    Umbraco.Extensions.ModelsBuilderConfigExtensions.GetModelsDirectory(string root, string config, bool acceptUnsafe)

    Does the directory need to be a sub-directory of something specific?

  • Jack 1 post 20 karma points
    May 07, 2021 @ 13:51
    Jack
    0

    I'm just getting to know Umbraco and started straight with version 9.

    I had the same issue. For me the solution was to add following format.

    "ModelsBuilder": {
            "ModelsMode": "AppData",
            "ModelsDirectory": "~/umbraco/models/"
          }
    

    Also I needed to change the build action for generated classes to "C# compiler" in order to avoid the missing namescapes error.

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    May 03, 2021 @ 13:15
    Paul Seal
    0

    That has done the trick, thank you

Please Sign in or register to post replies

Write your reply to:

Draft