Jun 21, 2014 at 9:32 AM
Edited Jun 21, 2014 at 9:33 AM
I need to add a field to a menu item, so I can assign a class to it. Here's what's not working: can anyone point me in the right direction please?
1) Click "Content Definition", and select the "Content Menu Item. I note:
- "stereotype" is "MenuItem", although I don't know what that means.
- Cointent Type ID is "ContentMenuItem", if that matters.
2) Click "Add Field" and add a "Text Field" called "Css Class". I don't understand the settings for this, but when I create it I can provide a "technical name", for which I use "CssClass". Save that.
Now I think I have successfully added a field to my menu items, and indeed I appear to be able to type and save text into those fields.
3) In my already cloned "MenuItem.cshtml" file, I now need to add this text field into the menu item. I can see by experiment that:
will add the class "THING" to my menu item, so I'm obviously in the right place and I know how to render the class to the output stream in the right place.
4) Now, I need to pull the value of the field I added from the "Content Menu Item". For this I can't get anything to work, and unfortunately it just crashes at run time with no useful information, and I can't get the debugger running on it without
changing the web.config, and I don't want to do that as chances are I'd break it even more.
Does anyone then know what the syntax to pull a field value out is? I've tried things like the following, based on googling lots of people talking about this type of thing:
Presumably I want some combination of these terms, but I can't work out which. I can see that there are both "content types" and "content parts", perhaps that's something to do with it. I don't want to get another PhD, I just want to render
the one field.... so really I just need the magic incantation, or a pointer to where I can read about what it is....