Copied to clipboard

Flag this post as spam?

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


  • S.Bhargava 13 posts 33 karma points
    Mar 30, 2012 @ 07:23
    S.Bhargava
    0

    Navigation Menu in Umbraco 5.0.1

    Can some one please explain how to mdify the default navigation menu in the umbraco 5.0.1 source code.

    I need to change the DynamicModel so that it accepts the custom navigation menu.Need to modify the @DynamicModel in the navigation.cshtml,so that i can have my own navigation menu

    @inherits RenderViewPage
    @using Umbraco.Cms.Web;

     @{
         var Homepage = @DynamicModel;
         while (Homepage.ContentType.Alias != "homePage")
         {
             Homepage = Homepage.Parent;
         }
     }
      <ul>
      <li><a href="@Homepage.Url">Home</a></li>
      @foreach (var item in Homepage.Children)
      {
          if (@item.CurrentTemplate != null)
          {
              var childName = item.Name ?? "(No name yet)";
              <li><a href="@item.Url">@childName </a></li>
          }
      }
      </ul>

    Thanks in advance

     

  • S.Bhargava 13 posts 33 karma points
    Apr 12, 2012 @ 09:03
    S.Bhargava
    0

    @inherits RenderViewPage

    @using Umbraco.Cms.Web;

    @{

         var Homepage = @DynamicModel;

         while (Homepage.ContentType.Alias != "homePage")

         {

             Homepage = Homepage.Parent;

     }

    }

     

    <div id="menuwrapper" style="display:inline;">

    <ul >

        <li><a href="@Homepage.Url">Home</a></li>

        @foreach (var item in Homepage.Children)

      {

          if (@item.CurrentTemplate != null)

          {

              var childName = item.Name ?? "(No name yet)";

             

            <li ><a href="@item.Url">@childName </a>

                 @*============ this is child menu ===========*@

                  <ul >

                        @if(item.Children != null)

                        {

                          foreach(var chil in item.Children)

                          {

                               var chilName = chil.Name ?? "(No name yet)";

     

                                    <li><a class="subAnchors" href="@chil.Url">@chilName</a>

                                      @*============ this is sub child menu ===========*@

                                            <ul >

                                                    @if(chil.Children != null)

                                                    {

                                                      foreach(var subChild in chil.Children)

                                                      {

                                                           var subchildName = subChild.Name ?? "(No name yet)";

     

                                                                <li><a class="subSubAnchors" href="@subChild.Url">@subchildName</a></li>

                                                      }

                                                    }

                                            </ul>

                                    </li>

                          }

                        }

                </ul>

            </li>

          

            

          }

      }

    </ul>

     

    </div>

     

     

    I have made the modifications to the default code as above,Now I can see Child menus and 3rd level child menus too.Hope would be useful to someone.And to change DynamicModel we have to modify it from the backoffice,I was ignorant.

  • S.Bhargava 13 posts 33 karma points
    Apr 13, 2012 @ 09:10
    S.Bhargava
    0

    Can anyone please say how the performance will be affected by the code i have modified...? I am starting to realize it is slowing the performance..?Any ideas how to show multilevel navigation menus from a partial view in umbrao 5.0.1 apart from the above code.......?

    waiting for the reply

    Thanks

  • Doug Robertson 121 posts 154 karma points
    Apr 24, 2012 @ 07:37
    Doug Robertson
    0

    I am trying out your code.  Thanks for that.

    What performance issues are you seeing?  Also, have you found a solution to the "Hide in Navigation" problem.  I don't want every single page showing up in my navigation.

    Thanks,

    Doug

     

Please Sign in or register to post replies

Write your reply to:

Draft