Sep 25, 2012 at 1:49 AM
Edited Sep 25, 2012 at 1:50 AM
Half of my problem was that I had added the "CssClass" text field to the "Custom Link" content type, rather than the "Menu" part (which is included in the Custom Link, HTML Menu Item & Content Menu Item content types).
After adding the field to the Menu part I can access it in the MenuItem.cshtml via @Model.Content.ContentItem.MenuPart.CssClass.Value
That said, I still have the situation where this partial view is in a base theme, and I may have a tenant that doesn't define the CssClass field on the menu part.
In the MenuItem.cshtml if I just try to check if its null as you suggested, I get the following exception:
Orchard.Core.Navigation.Models.MenuPart' does not contain a definition for 'CssClass'
So in the end I have added the following code to the partial view to iterate the fields on the parts...
foreach (var field in Model.Content.ContentItem.MenuPart.Fields)
if (field.Name == "CssClass")