November Happy Hour will be moved to Thursday December 5th.

Get property from main navigation page

Vote:
 

I want to have unique content for each drop down in my main navigation. So for each main nav item's drop down, you'd have a list of pages under that page (got that part) but then you'd also have custom content for that main nav item, like an image or anything else that would go in a Xhtmlstring Editor.

Any ideas?

#131664
Jul 31, 2015 18:42
Vote:
 

Here's the navigation view code I have currently...

@using EPiServer.Core
@using EPiServer
@using EPiServer.Filters
@using epiSalesDemo.Helpers
@using EPiServer.Web.Mvc.Html
@using EPiServer.ServiceLocation
@using EPiServer.SpecializedProperties
@using EPiServer.Web.Routing
@using epiSalesDemo.Models.Pages

@{
    var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
    var mainNavRef = contentLoader.GetChildren<PageData>(ContentReference.StartPage);
    var home = contentLoader.Get<HomePage>(ContentReference.StartPage);

    PageData sp = DataFactory.Instance.GetPage(PageReference.StartPage);

    bool showSecondLevelNavigation = true;
    bool showThirdLevelNavigation = false;

    PageRouteHelper pageRouteHelper = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<PageRouteHelper>();
    PageData currentPage = pageRouteHelper.Page;
    PageData parentPage = DataFactory.Instance.GetPage(currentPage.ParentLink);
    
}

<nav>
   <ul class="clearfix main-nav">
   @{
      IEnumerable<IContent> SubNav = new PageDataCollection();
      IEnumerable<IContent> ThirdNav = new PageDataCollection();

      foreach (PageData topLevelPage in mainNavRef)
      {
         if (topLevelPage.HasTemplate() && topLevelPage.VisibleInMenu && topLevelPage.IsVisibleOnSite())
         {
            bool IsCurrentPage = false;
            if (topLevelPage.ContentGuid == parentPage.ContentGuid) { IsCurrentPage = true; }
            IsCurrentPage = currentPage.PageGuid == topLevelPage.PageGuid || IsCurrentPage;

            @:<li class="@(IsCurrentPage ? "highlight" : "")">@Html.PageLink(topLevelPage)

            SubNav = contentLoader.GetChildren<PageData>(topLevelPage.ContentLink);
            bool weHaveSubPages = false;
            foreach (PageData subPage in SubNav)
            {
               if (subPage.HasTemplate() && subPage.VisibleInMenu && subPage.IsVisibleOnSite())
               {
               weHaveSubPages = true;
               }
            }
            if (weHaveSubPages && showSecondLevelNavigation)
            {
               @:<div class="nav-sub clearfix"><div class="large-6 column"><ul>
                   foreach (PageData subPage in SubNav)
                   {
                      if (subPage.HasTemplate() && subPage.VisibleInMenu && subPage.IsVisibleOnSite())
                      {
                         @:<li>@Html.PageLink(subPage)</li>
                      }
                   }
               @:</ul></div>

               @:<div class="large-6 show-for-large-up column">
                      DISPLAY CUSTOM CONTENT FROM MAIN NAV PAGE HERE
               @:</div></div>
            }
            @:</li>
         }
      }
   }
   </ul>
</nav>
#131665
Jul 31, 2015 18:47
Vote:
 

I think you could have your custom block that contains a ContentReference and other custom content you might have. Then your main navigation is list of your custom blocks

#131708
Aug 04, 2015 4:34
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.