How to Access a Field Added to a Content Type in code.

Topics: Customizing Orchard
Jan 26, 2012 at 7:12 AM

Hi all,

How could I access a custom field (i.e, ImageField) in a Content Item?

My scenario is that I made a Content Item that is Containable and has an Image Field part. I need to display the Image from the Image Field in a Container Widget alternate by modifying the `Parts.Common.Body.Summary-<MyContainableItem>`.

Thanks for the help and please let me know if I'm doing it wrong or there is already an existing solution to my problem.

Thanks

Coordinator
Jan 31, 2012 at 5:26 AM

Try:

dynamic c = yourContentItem;

var foo = c.NameOfTheContentType.NameOfTheField.SomePropertyOfTheField

Feb 1, 2012 at 6:52 AM

Hi,

Thanks, it worked great!