This project is read-only.

Getting Content Field Values

Topics: Customizing Orchard, General, Writing modules
Dec 27, 2011 at 3:50 PM
Edited Dec 27, 2011 at 3:51 PM

For the project I am working on, I need to be able to find the classification (from the Contrib.Taxonomies module) of a custom content part in order to filter them the way I need to.




public int Create()
    SchemaBuilder.CreateTable("NewPartRecord", tbl => tbl

    ContentDefinitionManager.AlterPartDefinition("NewPart", prt => prt.WithField.WithField("Classification", fld => fld.OfType("TaxonomyField")));

                cfg => cfg.WithPart("BodyPart")

    return 1;


After creating a piece of content from this content type, I am trying to determine what classification this item belongs to.




public ActionResult Index(int wantedTaxonomy)
    var parts = new List<ContentPart>();

    foreach (ContentPart part in DemoService.GetStuff())
        //find out what taxonomies part has

        if (taxonomy == wantedTaxonomy)

    return View(parts);

The commented portion is where I'm having trouble. I cant seem to find how to access the 
taxonomy field values within the ContentPart.

Any help would be appreciated. Thanks.


Dec 27, 2011 at 9:59 PM

shape tracing's Model tab can be pretty helpful for that sort of thing.

Dec 28, 2011 at 3:01 PM

That put me in the right direction. Thank you.