Using @Html.Action in a ResourcePackage Layout View

Posted by Community Admin on 05-Aug-2018 17:42

Using @Html.Action in a ResourcePackage Layout View

All Replies

Posted by Community Admin on 28-Jun-2016 00:00

I'm creating my Page Template to be used when site managers create new Pages for our website. Using the ResourcePackage structure I am creating new base templates that will have the content placeholders.  My goal is to not have a placeholder just for the Navigation widget, as I don't want other content items to be accidentally placed inside it. But I do want to use the Navigation widget to render my menu.

With MVC this should be as simple as calling an @Html.Action on the Navigation controller correct? When I use the code below, the correct Action and PartialView are loading, however, the Model for the PartialView is not aware of the context of my site. 

@Html.Action("GetView", "Navigation", new viewName = "NavigationView.SidePanel", model = new NavigationModel() SelectionMode = PageSelectionMode.TopLevelPages, OpenExternalPageInNewTab = true, LevelsToInclude = 2)

The html for the structure of my navigation loads, but without any menu items (ie, pages).

1.<div class="sidebar-menu">
2.  <!-- BEGIN SIDEBAR MENU ITEMS-->
3.  <ul class="menu-items">
4.  </ul>
5.</div>

What am I missing? Why is the context of my site not be set properly when creating the NavigationModel? This works and loads correctly when the widget is dragged into a placeholder.

This thread is closed