In the documentation it states that you can remove default views from the interface. I have added a new menu item tab with the following code:

Piranha.WebPages.Manager.Menu.Where(m => m.InternalId == "Content").Single().Items.Add(
     new Piranha.WebPages.Manager.MenuItem()
     {
         Name = "TSI Post",
         Action = "Index",
         Controller = "TSIPost",
         Permission = "ADMIN_POST"
     });

I want to remove the default Post tab.
I have attempted many variations of the following code.

 Piranha.WebPages.Manager.Menu.Where(m => m.InternalId == "Content").Single().Items.Remove(
     new Piranha.WebPages.Manager.MenuItem()
     {
         InternalId = "Posts",
         Name = "Posts",
         Action = "index",
         Controller = "post",
         Permission = "ADMIN_POST"
     });

What would be the proper syntax to remove the tab?

1

The problem with your second chunk of code is that you’re creating a totally new MenuItem that has not been added and then you try to remove it from the collection. This new object does not exist so nothing happens. To remove the default post page you’d probably need to write something like:

Manager.Menu.Where(m => m.InternalId == "Content")
  .Single().Items.Remove(
    Manager.Menu.Where(m => m.InternalId == "Content").Single()
      .Items.Where(i => i.InternalId == "Posts").Single());

This statement removes the item with the internal id “Posts” present in the current menu collection.

Regards

Håkan

0