Copied to clipboard

Flag this post as spam?

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


  • Matt 353 posts 825 karma points
    Aug 29, 2018 @ 07:52
    Matt
    0

    Hello,

    I'm trying to add meganav onto a new website, I pretty much copied over the code from an existing working website. But for some reason it doesnt seem to want to work on the new website.

    I've created my new partial view and I'm trying to link it into my Master Template using the following;

    @{
        var homeNode = Model.Content.Site().OfType<Home>();
        @Html.Partial("PartialMainNavigation", homeNode.MainNavigation)
    }
    

    But I'm getting the following error;

    Compiler Error Message: CS0246: The type or namespace name 'Home' could not be found (are you missing a using directive or an assembly reference?)

  • Nik 1591 posts 7148 karma points MVP 6x c-trib
    Aug 29, 2018 @ 07:58
    Nik
    0

    Hi Matt,

    Couple of questions for you.

    1) What version of Umbraco are you using? 2) Is Models Builder enabled? If so, what mode is it in? (This can be found in the App Settings of Web Config) 3) What is the document type of your root node? Is it "Home" or is it something different? If it's not got the alias of "home" it won't (I don't think) be mapping to a model of Home.

    Cheers,

    Nik

  • Matt 353 posts 825 karma points
    Aug 29, 2018 @ 08:10
    Matt
    0

    Hello Nik,

    Thanks for quick reply;

    1) My version is 7.12.1

    2) Model Builder is enabled with the following;

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

    3) My document type is indeed "Home"

    Thank you.

  • Matt 353 posts 825 karma points
    Aug 29, 2018 @ 08:23
    Matt
    0

    Hello Nik

    Hmm I seem to have fixed it, My Template was called Home Page so I just simply changed it to the following and it worked.

    var homeNode = Model.Content.Site().OfType<HomePage>();
    
  • Nik 1591 posts 7148 karma points MVP 6x c-trib
    Aug 29, 2018 @ 08:24
    Nik
    0

    No worries, sometimes it's easy to skip over a name thing. Pleased you've got it sorted now.

Please Sign in or register to post replies

Write your reply to:

Draft