Nov 4, 2015 at 2:40 PM
Edited Nov 4, 2015 at 2:41 PM
The following snippet demonstrates accessing an attached TextField
var myTextField = (TextField)Model.Content.ContentItem.MenuItem.MyField;
var myTextFieldValue = myTextField.Value;
The key is to know how to access the content item associated with the menu item. Once you have your hands on a content item, you can access its parts and fields.
In the case of the Custom Link (where its technical content type name is
), you attached the fields "directly" to the content type (MenuItem). However, Orchard can only attach fields to parts, so what it really did is creating a part called "MenuItem" and attached the fields to that one. That's
why you see ContentItem.MenuItem.MyField
(MenuItem is the part name you're accessing on the ContentItem).