Search code examples
piranha-cms

Admin Title not showing up after being dynamically added


I'm creating a new Piranha CMS application from scratch and I'm extending the administrative section to add another tab to the Content section. I'm adding this to the menu dynamically like this:

// create the product submenu item in Content master menu
        Manager.Menu.Where(m => m.InternalId == "Content").Single().Items.Add(
              new Manager.MenuItem()
              {
                  InternalId = "Product",
                  Name = "Product",
                  Action = "Index",
                  Controller = "ProductAdmin",
                  Permission = "ADMIN",
                  SelectedActions = "Index, Edit, Create"
              });

What other working admin menus the HTML look like is this

<div class="title">
<div class="container_12">
<div class="grid_12">
<h1>Pages</h1>
</div>
</div>
</div>

When I add this line to my View:

@Html.Partial("Partial/Tabs")

It generates this HTML (with H1 missing):

<div class="title">
<div class="container_12">
<div class="grid_12">
<h1></h1>
</div>
</div>
</div>

How do I get that H1 populated when adding tab dynamically?


Solution

  • The H1 is not populated by the menu object. The simple reason for this is that you might want to have the titles:

    • Products
    • Add new product
    • Edit product

    for different views that are all related to that one menu item. The H1 is populated by setting ViewBag.Title either in your views or in your controller actions.

    Regards

    Håkan