Query custom content type

Topics: Customizing Orchard, Writing modules
Mar 7, 2012 at 9:02 PM
Edited Mar 7, 2012 at 9:04 PM

I'm trying to use the new Query and Projector features in Orchard v1.4 with a content type I'm building using the following migration code:

	public int Create() {
			SchemaBuilder.CreateTable("WhatsNewRecord", table => table
				.ContentPartRecord()
			);

			//Make this content part attachable to any content type
			ContentDefinitionManager.AlterPartDefinition(typeof(WhatsNewPart).Name, c => c
				.Attachable()                 
				.WithField("Picture", cfg => cfg.OfType("MediaPickerField")
					.WithDisplayName("Thumbnail Image")
					.WithSetting("Required", true.ToString()))
				.WithField("Html", cfg => cfg.OfType("TextField")
					.WithDisplayName("Blurb")
					.WithSetting("Flavor", "Html")
					.WithSetting("Required", true.ToString()))
				.WithField("Url", cfg => cfg.OfType("LinkField")
					.WithDisplayName("Link for the Image")
					.WithSetting("LinkText", "Required")
					.WithSetting("TargetMode", "NewWindow")
					.WithSetting("Required", true.ToString())));

			ContentDefinitionManager.AlterTypeDefinition("Promotion", cfg => cfg
				.DisplayedAs("Promotion")
				.WithPart(typeof(WhatsNewPart).Name)
				.WithPart("CommonPart")
				.WithPart("ContainablePart")
				.WithPart("IdentityPart")
				.Draftable()
				.Creatable()
				.WithSetting("Description", "A promotional item"));

return 1;
}

I created a query that only filters on a ContentType = "Promotion" and displayed as a simple Html list. When I preview the query results or use it with a projection I only get the metadata (creation date) back for each Promotion. How can I include, say, the value of the TextField part in my query result?

Coordinator
Mar 8, 2012 at 1:16 AM
Edited Mar 8, 2012 at 1:16 AM

With placement. Or a property-based layout and maybe a few additional bindings.

Mar 8, 2012 at 12:59 PM

Placement was exactly my problem.

I use these parts in a widget as well and so I usually hide away the default rendering of each field. I forget that placement affects the admin screens as well. 

Thanks for the help.