Copied to clipboard

Flag this post as spam?

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


  • Matt 358 posts 841 karma points
    Apr 27, 2018 @ 08:40
    Matt
    0

    MegaNav Partial View

    Hello all,

    I'm using MegaNav but when I try to render the partial view I get the following error.

    > Compiler Error Message: CS1061:
    > 'Umbraco.Core.Models.IPublishedContent' does not contain a definition
    > for 'mainNavigation' and no extension method 'mainNavigation'
    > accepting a first argument of type
    > 'Umbraco.Core.Models.IPublishedContent' could be found (are you
    > missing a using directive or an assembly reference?)
    

    This is how I try to render the my partial view in my template;

    @Html.Partial("ExampleNavigation", Model.Content.mainNavigation)
    

    enter image description here

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Apr 27, 2018 @ 08:50
    Nik
    0

    Hi Matt,

    Do you have Models Builder enabled in your website? If so, Model.Content should be a typed model, what this means is that it should have a property on it called MainNavigation not mainNavigation, note the capital M at the start.

    Something to consider though, is that this approach won't work when you are trying to render the menu from a root/home node on subpages. So we might need to address that, but in the mean time lets get your menu rendering.

    Nik

  • Matt 358 posts 841 karma points
    Apr 27, 2018 @ 08:58
    Matt
    0

    Hello Nik,

    Thanks for the quick reply, how would I check Models Builder is enabled?

    I installed Meganav on my test website which worked fine, that had a captain M at the start but doesn't seem to work on the new website.

    Thanks

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Apr 27, 2018 @ 09:06
    Nik
    0

    Okay, so the quickest way to see if ModelsBuilder is enabled is look in your webconfig. In App Settings you should see an element called (I think) Models.Builder.Mode, by default it is set to PureLive.

    Nik

  • Matt 358 posts 841 karma points
    Apr 27, 2018 @ 09:10
    Matt
    0

    Hello Nik,

    Here is what I have;

        <add key="Umbraco.ModelsBuilder.Enable" value="true" />
        <add key="Umbraco.ModelsBuilder.ModelsMode" value="PureLive" />
    
  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Apr 27, 2018 @ 09:21
    Nik
    0

    Okay, so looks like you have Models Builder enabled.

    Could you provide an image of what your site structure looks like in the content tree?

  • Matt 358 posts 841 karma points
    Apr 27, 2018 @ 09:24
    Matt
    0

    Here you go Nik, strange how it worked on my test....

    enter image description here

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Apr 27, 2018 @ 09:29
    Nik
    0

    Thanks Matt, and to confirm this property: Main Navigation is on the Home document type yes?

    Is your call from your partial view being called from a shared layout file that all the other templates use?

    Nik

  • Matt 358 posts 841 karma points
    Apr 27, 2018 @ 09:32
    Matt
    0

    Hello Nik,

    Yeap its in my home document type

    enter image description here

    Yes it is, The partial view is in my Master template

    Thanks Matt

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Apr 27, 2018 @ 09:37
    Nik
    0

    Okay,

    Try this code:

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

    Basically, your master layout doesn't know the type of your current page so using the direct property access doesn't work.

    However, what you can do is get your root node from your current node by using .Site(). You can then use the .OfType extension method to convert the IPublishedContent it returns to the strongly typed model from Models Builder for your Home node. Then you can access the MainNavigation property. Doing this will also make it work for sub pages as well.

    Nik

  • Matt 358 posts 841 karma points
    Apr 27, 2018 @ 09:42
    Matt
    0

    Hello Nik,

    Thanks that makes a little more sense why it isn't working.

    I tried adding your code to my master template but still getting the same error;

    Compiler Error Message: CS1061: 'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'MainNavigation' and no extension method 'MainNavigation' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found (are you missing a using directive or an assembly reference?)
    

    Sorry!

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Apr 27, 2018 @ 09:45
    Nik
    0

    No problem, can I see your entire master layout? and also the code for the navigation partial? (Just incase Razor is being annoying and saying the error is somewhere it isn't)

  • Matt 358 posts 841 karma points
    Apr 27, 2018 @ 09:52
    Matt
    0

    Hello Nik,

    Here is my Master Template;

        @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    }
    
    @{
        var homeNode = Model.Content.Site().OfType<Home>();
        @Html.Partial("ExampleNavigation", homeNode.MainNavigation)
    }
    
    <!DOCTYPE html>
    
    <html>
    <head>
    
        <title>Information Governance - General Data Protection Regulation (GDPR)</title>
    
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta content="width=device-width, initial-scale=1" name="viewport">
    
        <link href="~/css/normalize.css" rel="stylesheet" type="text/css">
        <link href="~/css/components.css" rel="stylesheet" type="text/css">
        <link href="~/css/igwebsite.css" rel="stylesheet" type="text/css">
        <link href="~/css/flipclock.css" rel="stylesheet" type="text/css">
    
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js" type="text/javascript"></script>
        <script type="text/javascript">WebFont.load({ google: { families: ["Droid Sans:400,700"] } });</script>
        <!-- [if lt IE 9]><script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js" type="text/javascript"></script><![endif] -->
        <script type="text/javascript">!function (o, c) { var n = c.documentElement, t = " w-mod-"; n.className += t + "js", ("ontouchstart" in o || o.DocumentTouch && c instanceof DocumentTouch) && (n.className += t + "touch") }(window, document);</script>
        <link href="~/images/favicon.ico" rel="icon" type="image/x-icon">
        <script src="~/scripts/flipclock.min.js"></script>
        <script src="~/scripts/Main.js"></script>
    
    </head>
    
    <body class="body">
        <div class="header-section">
            <div class="header-container w-container">
                <div class="row w-row">
                    <div class="w-col w-col-3">
                        <div class="left-header-div">
                            <img src="~/images/logo.png" width="117" class="mobile-logo w-hidden-main w-hidden-medium">
                            <h1 class="ig-privacy-logo">IG Privacy</h1>
                            <div>Information Governance</div>
                        </div>
                    </div>
                    <div class="w-col w-col-6">
                        <div class="middle-header-div">
                            <h4 class="middle-header-title">Connecting and protecting healthcare information</h4>
                        </div>
                    </div>
                    <div class="w-col w-col-3">
                        <div class="right-section-div w-clearfix">
                            <img src="~/images/logo.png" width="117" class="image w-hidden-small w-hidden-tiny">
                            <div class="search-box w-clearfix">
                                    <form action="~/search" method="post">
                                        <input type="text" placeholder="Search..." name="query">
                                        <input type="image" src="~/images/search.png" class="submitsearch" />
                                    </form>
                            </div>
                        </div>
                    </div>
                </div>
    
    
    
    @Html.Partial("ExampleNavigation", Model.Content.MainNavigation)
    
    
                <div data-collapse="medium" data-animation="default" data-duration="400" class="navbar w-nav">
                    <div class="nav-container w-container">
                        <nav role="navigation" class="nav-menu w-nav-menu">
                            <nav role="navigation" class="nav-menu w-nav-menu">
                            <a href="~/" class="nav-link w-nav-link">Home</a>
                            <div data-hover="1" data-delay="0" class="drop-down-menu w-dropdown">
                                <div class="nav-link w-dropdown-toggle">
                                    <div>About</div>
                                </div>
                                <nav class="w-dropdown-list"><a href="~/about-us" class="drop-down-link w-dropdown-link">About us</a><a href="~/ig-team" class="drop-down-link w-dropdown-link">Your IG team</a></nav>
                            </div>
                            <div data-hover="1" data-delay="0" class="drop-down-menu w-dropdown">
                                <div class="nav-link w-dropdown-toggle">
                                    <div>How we use data</div>
                                </div>
                                <nav class="w-dropdown-list"><a href="#" class="drop-down-link w-dropdown-link">Our pledge to you</a><a href="#" class="drop-down-link w-dropdown-link">How we collect data</a><a href="#" class="drop-down-link w-dropdown-link">How and why we share data</a><a href="~/what-data-we-hold-about-you" class="drop-down-link w-dropdown-link">What data do you hold about me?</a></nav>
                            </div>
                            <div data-hover="1" data-delay="0" class="drop-down-menu w-dropdown">
                                <div class="nav-link w-dropdown-toggle">
                                    <div>Your rights</div>
                                </div>
                                <nav class="w-dropdown-list"><a href="~/your-rights" class="drop-down-link w-dropdown-link">Your rights</a><a href="~/complaints-procedure.html" class="drop-down-link w-dropdown-link">Complaints procedure</a></nav>
                            </div>
                            <div data-hover="1" data-delay="0" class="drop-down-menu w-dropdown">
                                <div class="nav-link w-dropdown-toggle">
                                    <div>Resources</div>
                                </div>
                                <nav class="w-dropdown-list"><a href="#" class="drop-down-link w-dropdown-link">Interactive tools</a><a href="#" class="drop-down-link w-dropdown-link">How do I keep safe online?</a></nav>
                            </div>
                            <div data-hover="1" data-delay="0" class="drop-down-menu w-dropdown">
                                <div class="nav-link w-dropdown-toggle">
                                    <div>Asset Managment</div>
                                </div>
                                <nav class="w-dropdown-list"><a href="#" class="drop-down-link w-dropdown-link">Information Assets</a><a href="#" class="drop-down-link w-dropdown-link">Record logs</a><a href="#" class="drop-down-link w-dropdown-link">Templates</a><a href="#" class="drop-down-link w-dropdown-link">Audit</a></nav>
                            </div>
                            <a href="~/policies-procedures-and-guidance" class="nav-link w-nav-link">Policies/Guidance</a><a href="#" class="nav-link w-nav-link">GDPR</a><a href="~/blog" class="nav-link w-nav-link">Blog</a><a href="~/Contact" class="nav-link w-nav-link">Contact us</a>
                        </nav>
                        <div class="menu-button w-nav-button">
                            <div class="mobile-icon w-icon-nav-menu"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    
        @RenderBody()
    
        <div class="footer-new">
            <div class="footer-container w-container">
                <div class="w-row">
                    <div class="w-col w-col-6">
                        <div class="footer-col1-div">
                            <h2 class="footer-logo">IG Privacy</h2>
                            <div class="footer-adress">
                                <div class="text-block-5">Footer Adress</div>
                            </div>
                            <div class="line-divider-footer"></div>
                            <div class="footer-contact w-clearfix">
                                <div class="footer-contact-text footer-phone">01722 336262</div>
                                <div class="footer-contact-text footer-email">[email protected]</div>
                                <div class="text-block-6">Our Values</div>
                            </div><img src="~/images/values_final.gif">
                        </div>
                    </div>
                    <div class="w-col w-col-3">
                        <div class="footer-col2-div">
                            <p class="footer-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique, Lorem ipsum dolor sit amet, consectetur adipiscing elit.Suspendisse varius enim in eros elementum tristique. Suspendisse varius enim in eros elementum tristique.</p>
                        </div>
                    </div>
                    <div class="w-col w-col-3">
                        <div class="footer-col3-div">
                            <ul>
                                <li class="footer-list"><a href="~/about-us" class="footer-link-new">About us</a></li>
                                <li class="footer-list"><a href="#" class="footer-link-new">Privacy Notice</a></li>
                                <li class="footer-list"><a href="#" class="footer-link-new">Freedom of information</a></li>
                                <li class="footer-list"><a href="#" class="footer-link-new">Confidentiality</a></li>
                                <li class="footer-list"><a href="~/ig-glossary" class="footer-link-new">Glossary</a></li>
                                <li class="footer-list"><a href="#" class="footer-link-new">Policies</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="copyright">
                    <div class="copyright-text">&copy; <script type="text/javascript">
     var theDate=new Date()
     document.write(theDate.getFullYear())
     </script> Name here</div>
                </div>
            </div>
        </div>
        @*<script src="https://code.jquery.com/jquery-3.3.1.min.js" type="text/javascript" intergrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>*@
        <script src="~/scripts/igwebsite.js" type="text/javascript"></script>
        <!-- [if lte IE 9]><script src="https://cdnjs.cloudflare.com/ajax/libs/placeholders/3.0.2/placeholders.min.js"></script><![endif] -->
    </body>
    </html>
    

    And here is my ExampleNavigation.cshtml Partial view;

    @using Cogworks.Meganav.Models
    @model IEnumerable<MeganavItem>
    
    @RenderNavigation(Model)
    
    @helper RenderNavigation(IEnumerable<MeganavItem> items)
    {
        if (items.Any())
        {
            <ul>
                @foreach (var item in items)
                {
                    <li>
                        <a href="@item.Url" target="@item.Target">
                            @item.Title (Level: @item.Level)
                        </a>
    
                        @RenderNavigation(item.Children)
                    </li>
                }
            </ul>
        }
    }
    
  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Apr 27, 2018 @ 09:55
    Nik
    100

    Hi Matt,

    In your master template you still have:

    @Html.Partial("ExampleNavigation", Model.Content.MainNavigation)
    

    Delete that line and replace it with:

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

    Don't put that at the top like you currently have :-)

    Nik

  • Matt 358 posts 841 karma points
    Apr 27, 2018 @ 10:01
    Matt
    1

    Aha!

    Working like a dream, I owe you a drink!

  • Matt 358 posts 841 karma points
    Apr 27, 2018 @ 12:38
    Matt
    0

    Hello Nik,

    Would you know why I'm getting this error

    CS1061: 'Cogworks.Meganav.Models.MeganavItem' does not contain a definition for 'Child' and no extension method 'Child'
    

    When using @item.Child

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Apr 27, 2018 @ 12:46
    Nik
    0

    Hi Matt,

    That would be because the MegaNav item model doesn't have a property of method called Child.

    You can access Child items by using the Children property.

    Nik

  • Matt 358 posts 841 karma points
    Apr 27, 2018 @ 12:51
    Matt
    0

    Ah ok.

    My issue is that I want to style each of the Children;

     if (items.Any())
            {
                    foreach (var item in items)
                    {
            <div data-hover="1" data-delay="0" class="drop-down-menu w-dropdown">
                <div class="nav-link w-dropdown-toggle">
                    <div><a href="@item.Url" class="nav-link w-nav-link">@item.Title</a></div>
                </div>
    
    
                <nav class="w-dropdown-list">@RenderNavigation(item.Children)</nav>
    
            </div>
    
    
                    }
            }
    

    So as I'm just using @RenderNavigation(item.Children) do you know how could i add a class to those "Render links" ?

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Apr 27, 2018 @ 12:53
    Nik
    0

    Is that your full navigation partial?

  • Matt 358 posts 841 karma points
    Apr 27, 2018 @ 13:00
    Matt
    0

    Sorry no here it is;

    <div data-collapse="medium" data-animation="default" data-duration="400" class="navbar w-nav">
        <div class="nav-container w-container">
        <nav role="navigation" class="nav-menu w-nav-menu">
        @using Cogworks.Meganav.Models
        @model IEnumerable<MeganavItem>
    
        @RenderNavigation(Model)
    
        @helper RenderNavigation(IEnumerable<MeganavItem> items)
    
        {
    
            if (items.Any())
            {
                    foreach (var item in items)
                    {
            <div data-hover="1" data-delay="0" class="drop-down-menu w-dropdown">
                <div class="nav-link w-dropdown-toggle">
                    <div><a href="@item.Url" class="nav-link w-nav-link">@item.Title</a></div>
                </div>
    
    
                <nav class="w-dropdown-list">@RenderNavigation(item.Children)</nav>
    
            </div>
    
    
                    }
            }
        }
            </nav>
        <div class="menu-button w-nav-button">
        <div class="mobile-icon w-icon-nav-menu"></div>
            </div>
            </div>
        </div>
    
  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Apr 27, 2018 @ 13:05
    Nik
    0

    So, what should a link that doesn't have children look like compared to a link that does have children? Can you provide snippets of the html you are expecting?

  • Matt 358 posts 841 karma points
    Apr 27, 2018 @ 13:09
    Matt
    0

    Hello Nik,

    So what I am trying to do is style the nav link;

    Here is the html version;

    <nav class="w-dropdown-list">
    <a href="#" class="drop-down-link w-dropdown-link">Link 1</a>
    </nav>
    

    So in theory I need to add the class "drop-down-link w-dropdown-link" to the children.

    I thought I could do something like this;

    <nav class="w-dropdown-list">
    <a href="#" class="drop-down-link w-dropdown-link">@item.Children</a>
    </nav>
    

    But @item.Children doesn't seem to work.

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Apr 27, 2018 @ 13:21
    Nik
    0

    Matt, could you create a plain HTML version of what you want your full navigation to look like? With the correct classes in place and examples of no children and multiple children?

    So what you want your HTML to look like if your structure was this:

    • Home
    • About
      • About level 1
      • About level 1
      • About level 1
    • Contact

    Also, how many levels deep would your menu go?

  • Matt 358 posts 841 karma points
    Apr 27, 2018 @ 13:29
    Matt
    0

    Hello Nik

    Here is sample of just HTML with drop downs, I plan to only have 1 level.

            <div data-collapse="medium" data-animation="default" data-duration="400" class="navbar w-nav">
                <div class="nav-container w-container">
                    <nav role="navigation" class="nav-menu w-nav-menu">
                        <nav role="navigation" class="nav-menu w-nav-menu">
                        <a href="~/" class="nav-link w-nav-link">Home</a>
                        <div data-hover="1" data-delay="0" class="drop-down-menu w-dropdown">
                            <div class="nav-link w-dropdown-toggle">
                                <div>About</div>
                            </div>
                            <nav class="w-dropdown-list"><a href="~/about-us" class="drop-down-link w-dropdown-link">Drop down Link 1</a><a href="~/ig-team" class="drop-down-link w-dropdown-link">Drop down link 2</a></nav>
                        </div>
                        <div data-hover="1" data-delay="0" class="drop-down-menu w-dropdown">
                            <div class="nav-link w-dropdown-toggle">
                                <div>How we use data</div>
                            </div>
                            <nav class="w-dropdown-list"><a href="#" class="drop-down-link w-dropdown-link">Drop down link 1</a></nav>
                        </div>
                        <div data-hover="1" data-delay="0" class="drop-down-menu w-dropdown">
                            <div class="nav-link w-dropdown-toggle">
                                <div>Your rights</div>
                            </div>
                            <nav class="w-dropdown-list"><a href="~/your-rights" class="drop-down-link w-dropdown-link">Your rights</a><a href="~/complaints-procedure.html" class="drop-down-link w-dropdown-link">Complaints procedure</a></nav>
                        </div>
                        <a href="~/policies-procedures-and-guidance" class="nav-link w-nav-link">Policies/Guidance</a><a href="#" class="nav-link w-nav-link">GDPR</a><a href="~/blog" class="nav-link w-nav-link">Blog</a><a href="~/Contact" class="nav-link w-nav-link">Contact us</a>
                    </nav>
                    <div class="menu-button w-nav-button">
                        <div class="mobile-icon w-icon-nav-menu"></div>
                    </div>
                </div>
            </div>
    
  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Apr 27, 2018 @ 13:47
    Nik
    1

    Hi Matt,

    There is probably some code errors in this but, this is roughly what I would do:

    @using Cogworks.Meganav.Models
    @model IEnumerable<MeganavItem>
    
    <div data-collapse="medium" data-animation="default" data-duration="400" class="navbar w-nav">
    <div class="nav-container w-container">
        <nav role="navigation" class="nav-menu w-nav-menu">
    
            //The top level requires different rendering to children so let us split it up.
            @foreach(var topLevelEntry in Model)
            {
                //We need to check if this has children or not
                if(topLevelEntry.Children != null && topLevelEntry.Children.Any())
                {
                    <div data-hover="1" data-delay="0" class="drop-down-menu w-dropdown">
                        <div class="nav-link w-dropdown-toggle">
                            <div>@topLevelEntry.Title</div>
                        </div>
                        <nav class="w-dropdown-list">
                            @RenderChildren(topLevelEntry.Children)                        
                        </nav>
                    </div>
                }else{
                    <a href="@topLevelEntry.Url" class="nav-link w-nav-link">@topLevelEntry.Title</a>
                }
            }
        </nav>
        <div class="menu-button w-nav-button">
            <div class="mobile-icon w-icon-nav-menu"></div>
        </div>
    </div>
    

    @helper RenderChildren(IEnumerable<MeganavItem> items)
    {
        if (items.Any())
        {
            foreach (var item in items)
            {        
                <a href="@item.Url" class="drop-down-link w-dropdown-link">@item.Title</a>
            }
        }
    }  
    
  • Matt 358 posts 841 karma points
    Apr 27, 2018 @ 13:53
    Matt
    0

    Hello Nik,

    Great I shall give it try, Sorry I'm competly new and trying to learn this language.

    @helper RenderChildren(IEnumerable<MeganavItem> items)
    {
        if (items.Any())
        {
            foreach (var item in items)
            {        
                <a href="@item.Url" class="drop-down-link w-dropdown-link">@item.Title</a>
            }
        }
    }  
    

    Should this go at the bottom of the page?

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Apr 27, 2018 @ 13:57
    Nik
    1

    It's not a problem Matt, no need to apologise,

    Yep, put that at the bottom of your navigation partial view.

    If you have questions about what it's doing, let me know and I'll try and explain it.

    Nik

  • Matt 358 posts 841 karma points
    Apr 27, 2018 @ 14:22
    Matt
    0

    Hello Nik,

    That worked a treat, thank you. 2 weeks I been trying to get this working!

    I've took up lots of your time up already today, but if you get some spare time it would be great if you can explain it.

    Matt

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Apr 27, 2018 @ 14:23
    Nik
    1

    I'll see what I can do, but it won't be today. I'll try and get an explanation written over the weekend for you :-)

  • Zubair Hasan 18 posts 88 karma points notactivated
    Oct 29, 2018 @ 12:53
    Zubair Hasan
    0

    Need someone help. I'm implementing the meganav but different errors occurred. I have read the discussion of Nik and Matt and try this but failed with an error.

    Error is "Object reference not set to an instance of an object." Line 91: @{ Line 92: var homeNode = Model.Content.Site().OfType

  • louisjrdev 107 posts 344 karma points c-trib
    Oct 29, 2018 @ 13:56
    louisjrdev
    0

    Hi Zubair,

    Please ensure the code is

     var homeNode = Model.Content.Site().OfType<YOUR_HOME_MODEL_HERE>();
    

    and not

     var homeNode = Model.Content.Site().OfType
    
  • Zubair Hasan 18 posts 88 karma points notactivated
    Oct 29, 2018 @ 14:43
    Zubair Hasan
    0

    I'm sending you my masterpage code + menus code + ExampleNavigation

    Master Page:

    @inherits UmbracoTemplatePage

    @{ Layout = null; }

    <meta charset="utf-8">
    <meta name="keywords" content="HTML5 Template" />
    
    <meta name="description" content="">
    <meta name="author" content="">
    
    <title>DLMS</title>
    
    
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
    
    <link rel="shortcut icon" href="./favicon.ico">
    
    
    <link rel="stylesheet" href="css/font-awesome/css/font-awesome.css">
    
    <link rel="stylesheet" href="css/bootstrap.min.css">
    
    <link rel="stylesheet" href="css/prettyphoto.css">
    
    <link rel="stylesheet" href="css/pe-icon-7-stroke/css/pe-icon-7-stroke.css">
    
    <link rel="stylesheet" href="/css/vendors/owl-carousel/owl.theme.css">
    
    <link rel="stylesheet" href="/css/vendors/owl-carousel/owl.carousel.css">
    
    <link rel="stylesheet" href="/css/vendors/owl-carousel/owl.transitions.css">
    
    <link rel="stylesheet" href="/css/vendors/slick/slick.css">
    
    <link rel="stylesheet" href="css/style.css">
    
    <link rel='stylesheet' href="/css/revolution/css/settings.css" type="text/css">
    
    <link rel='stylesheet' href="/css/revolution/css/layers.css" type="text/css">
    
    <link rel='stylesheet' href="/css/revolution/css/navigation.css" type="text/css">
    
    <link rel='stylesheet' href="/css/revolution/css/settings2.css" type="text/css">
    
    <link rel='stylesheet' href="/css/revolution/css/settings3.css" type="text/css">
    
    
    
    <!--[if lt IE 9]>
    
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    
    <![endif]-->
    

      @@{ var homeNode = Model.Content.Site().OfType@ @Html.Partial("PVMaster")

    @RenderBody()
    
    <script src="/Scripts/jquery.js"></script>
    <script src="/Scripts/bootstrap.min.js"></script>
    <script src="/Scripts/vendors/owl-carousel/owl.carousel.min.js"></script>
    <script src="/Scripts/vendors/easypie/jquery.easypiechart.min.js"></script>
    <script src="/Scripts/vendors/slick/slick.min.js"></script>
    <script src="/Scripts/vendors/jquery.counterup.min.js"></script>
    <script src="/Scripts/vendors/waypoints.min.js"></script>
    <script src="/Scripts/vendors/tweecool.min.js"></script>
    <script src="/Scripts/vendors/snap.min.js"></script>
    <script src="/Scripts/vendors/jquery.prettyPhoto.js"></script>
    <script src="/Scripts/main.js"></script>
    <script src="/Scripts/vendors/isotope/isotope.pkgd.js"></script>
    <script src="/Scripts/vendors/isotope/main.js"></script>
    <script type='text/javascript' src='/Scripts/revolution/js/jquery.themepunch.tools.min.js'></script>
    <script type='text/javascript' src='/Scripts/revolution/js/jquery.themepunch.revolution.min.js'></script>
    <script type='text/javascript' src='/Scripts/revolution/js/jquery.themepunch.essential.min.js'></script>
    <script type='text/javascript' src='/Scripts/revolution/js/extensions/jquery.themepunch.essential.min.js'></script>
    <script type="text/javascript" src="/Scripts/revolution/js/extensions/revolution.extension.slideanims.min.js"></script>
    <script type="text/javascript" src="/Scripts/revolution/js/extensions/revolution.extension.actions.min.js"></script>
    <script>
        $(document).ready(function () {
            $(".owl-carousel").owlCarousel({
                margin: 10,
                loop: true,
                autoWidth: true,
                items: 4,
                nav: true
            });
        });
    </script>
    
    <script type="text/javascript" src="/Scripts/revolution/js/extensions/revolution.extension.layeranimation.min.js"></script>
    <script type="text/javascript" src="/Scripts/revolution/js/extensions/revolution.extension.navigation.min.js"></script>
    <script type="text/javascript" src="/Scripts/revolution/js/extensions/revolution.extension.parallax.min.js"></script>
    <script type="text/javascript" src="/Scripts/revolution/main.js"></script>
    

    Menus

    @inherits UmbracoTemplatePage

    ExampleNavigation

    @using Cogworks.Meganav.Models @model IEnumerable

    @RenderNavigation(Model)

    @helper RenderNavigation(IEnumerable

  • Zubair Hasan 18 posts 88 karma points notactivated
    Oct 29, 2018 @ 14:45
    Zubair Hasan
    0

    I have changed it little bit and sent you the new code. New Master page code is here:

    @inherits UmbracoTemplatePage

    @{ Layout = null; }

    <meta charset="utf-8">
    <meta name="keywords" content="HTML5 Template" />
    
    <meta name="description" content="">
    <meta name="author" content="">
    
    <title>DLMS</title>
    
    
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
    
    <link rel="shortcut icon" href="./favicon.ico">
    
    
    <link rel="stylesheet" href="css/font-awesome/css/font-awesome.css">
    
    <link rel="stylesheet" href="css/bootstrap.min.css">
    
    <link rel="stylesheet" href="css/prettyphoto.css">
    
    <link rel="stylesheet" href="css/pe-icon-7-stroke/css/pe-icon-7-stroke.css">
    
    <link rel="stylesheet" href="/css/vendors/owl-carousel/owl.theme.css">
    
    <link rel="stylesheet" href="/css/vendors/owl-carousel/owl.carousel.css">
    
    <link rel="stylesheet" href="/css/vendors/owl-carousel/owl.transitions.css">
    
    <link rel="stylesheet" href="/css/vendors/slick/slick.css">
    
    <link rel="stylesheet" href="css/style.css">
    
    <link rel='stylesheet' href="/css/revolution/css/settings.css" type="text/css">
    
    <link rel='stylesheet' href="/css/revolution/css/layers.css" type="text/css">
    
    <link rel='stylesheet' href="/css/revolution/css/navigation.css" type="text/css">
    
    <link rel='stylesheet' href="/css/revolution/css/settings2.css" type="text/css">
    
    <link rel='stylesheet' href="/css/revolution/css/settings3.css" type="text/css">
    
    
    
    <!--[if lt IE 9]>
    
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    
    <![endif]-->
    

      @{ var homeNode = Model.Content.Site().OfType

    @RenderBody()
    
    <script src="/Scripts/jquery.js"></script>
    <script src="/Scripts/bootstrap.min.js"></script>
    <script src="/Scripts/vendors/owl-carousel/owl.carousel.min.js"></script>
    <script src="/Scripts/vendors/easypie/jquery.easypiechart.min.js"></script>
    <script src="/Scripts/vendors/slick/slick.min.js"></script>
    <script src="/Scripts/vendors/jquery.counterup.min.js"></script>
    <script src="/Scripts/vendors/waypoints.min.js"></script>
    <script src="/Scripts/vendors/tweecool.min.js"></script>
    <script src="/Scripts/vendors/snap.min.js"></script>
    <script src="/Scripts/vendors/jquery.prettyPhoto.js"></script>
    <script src="/Scripts/main.js"></script>
    <script src="/Scripts/vendors/isotope/isotope.pkgd.js"></script>
    <script src="/Scripts/vendors/isotope/main.js"></script>
    <script type='text/javascript' src='/Scripts/revolution/js/jquery.themepunch.tools.min.js'></script>
    <script type='text/javascript' src='/Scripts/revolution/js/jquery.themepunch.revolution.min.js'></script>
    <script type='text/javascript' src='/Scripts/revolution/js/jquery.themepunch.essential.min.js'></script>
    <script type='text/javascript' src='/Scripts/revolution/js/extensions/jquery.themepunch.essential.min.js'></script>
    <script type="text/javascript" src="/Scripts/revolution/js/extensions/revolution.extension.slideanims.min.js"></script>
    <script type="text/javascript" src="/Scripts/revolution/js/extensions/revolution.extension.actions.min.js"></script>
    <script>
        $(document).ready(function () {
            $(".owl-carousel").owlCarousel({
                margin: 10,
                loop: true,
                autoWidth: true,
                items: 4,
                nav: true
            });
        });
    </script>
    
    <script type="text/javascript" src="/Scripts/revolution/js/extensions/revolution.extension.layeranimation.min.js"></script>
    <script type="text/javascript" src="/Scripts/revolution/js/extensions/revolution.extension.navigation.min.js"></script>
    <script type="text/javascript" src="/Scripts/revolution/js/extensions/revolution.extension.parallax.min.js"></script>
    <script type="text/javascript" src="/Scripts/revolution/main.js"></script>
    

  • Zubair Hasan 18 posts 88 karma points notactivated
    Oct 29, 2018 @ 14:50
    Zubair Hasan
    0

    @inherits UmbracoTemplatePage

    @{ Layout = null; } . . . .

      @{ var homeNode = Model.Content.Site().OfType

  • louisjrdev 107 posts 344 karma points c-trib
    Oct 29, 2018 @ 14:52
    louisjrdev
    0

    This snippet of your code here:

    @{
          var homeNode = Model.Content.Site().OfType();
          @Html.Partial("ExampleNavigation", homeNode.MenuBar)
    }
    

    on this line:

     var homeNode = Model.Content.Site().OfType();
    

    it needs to pass in a Model Class to the .OfType()

    so it would need to be this:

    var homeNode = Model.Content.Site().OfType<Home>();
    

    replacing "Home" with your Home Model's class name

  • Zubair Hasan 18 posts 88 karma points notactivated
    Oct 29, 2018 @ 14:55
    Zubair Hasan
    0

    I have tried this

    @{ var homeNode = Model.Content.Site().OfType

    but it gives an error

    Object reference not set to an instance of an object. @{ Line 97: var homeNode = Model.Content.Site().OfType

  • louisjrdev 107 posts 344 karma points c-trib
    Oct 29, 2018 @ 14:56
    louisjrdev
    0

    Okay what is the alias of the DocType for your home node?

  • Zubair Hasan 18 posts 88 karma points notactivated
    Oct 29, 2018 @ 14:57
    Zubair Hasan
    0

    Sorry for the previous post. My code look like
    @{ var homeNode = Model.Content.Site().OfType

  • Zubair Hasan 18 posts 88 karma points notactivated
    Oct 29, 2018 @ 14:59
    Zubair Hasan
    0
    @{var homeNode = Model.Content.Site().OfType<Menus>();
    
    @Html.Partial("ExampleNavigation", homeNode.MenuBar)}
    
  • Zubair Hasan 18 posts 88 karma points notactivated
    Oct 29, 2018 @ 15:00
    Zubair Hasan
    0

    Menus named doctype with alias menuBar

  • louisjrdev 107 posts 344 karma points c-trib
    Oct 29, 2018 @ 15:03
    louisjrdev
    0

    Hi Zubair,

    Do you have a model for your homepage?

    If you do what is the name of the class? (the .cs file)

  • Zubair Hasan 18 posts 88 karma points notactivated
    Oct 30, 2018 @ 09:17
    Zubair Hasan
    0

    @{ var homeNode = Model.Content.AncestorOrSelf(1); @Html.Partial("ExampleNavigation", homeNode.MenuBar) }

    Still gives compilation error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS1061: 'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'MenuBar' and no extension method 'MenuBar' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found (are you missing a using directive or an assembly reference?)

  • Zubair Hasan 18 posts 88 karma points notactivated
    Oct 30, 2018 @ 09:23
    Zubair Hasan
    0

    No I haven't any model related to meganav or menus documents (doc type). I have read some other post that are used to make navigation using multinode tree picker but failed..... These navigation class makes thier own models and controllers.

  • Zubair Hasan 18 posts 88 karma points notactivated
    Oct 30, 2018 @ 11:02
    Zubair Hasan
    0

    all.generated.cs does not update models definition like I have made Menus.cshtml then I go to all.generated.cs and copy paste the definition of previous model (like category document type) and then change previous model definition to new one (Menus document type). New definition is:

        /// <summary>Menus</summary>
    [PublishedContentModel("menus")]
    public partial class Menus : PublishedContentModel
    {
    

    pragma warning disable 0109 // new is redundant

        public new const string ModelTypeAlias = "menus";
        public new const PublishedItemType ModelItemType = PublishedItemType.Content;
    

    pragma warning restore 0109

        public Menus(IPublishedContent content)
            : base(content)
        { }
    

    pragma warning disable 0109 // new is redundant

        public new static PublishedContentType GetModelContentType()
        {
            return PublishedContentType.Get(ModelItemType, ModelTypeAlias);
        }
    

    pragma warning restore 0109

        public static PublishedPropertyType GetModelPropertyType<TValue>(Expression<Func<Menus, TValue>> selector)
        {
            return PublishedContentModelUtility.GetModelPropertyType(GetModelContentType(), selector);
        }
    
        ///<summary>
        /// MenuBar
        ///</summary>
        [ImplementPropertyType("menuBar")]
        public IEnumerable<Cogworks.Meganav.Models.MeganavItem> MenuBar
        {
            get { return this.GetPropertyValue<IEnumerable<Cogworks.Meganav.Models.MeganavItem>>("menuBar"); }
        }
    }
    

    I just want to ask that is there any problem. Same I have done with models.generated.cs.

Please Sign in or register to post replies

Write your reply to:

Draft