chaz stone
chaz stone

Reputation: 89

Sitefinity 5.1 iterating over content types

i'm kinda new to Sitefinity 5.1 just to state that up front. i've created a custom content type and given it some properties. i'm trying to create a user control that gets each item of this content type and displays some of the attributes in a panel. what i'm looking for is how to directly interact with this collection.

thanks.

Upvotes: 1

Views: 246

Answers (2)

Radoslav Radoslavov
Radoslav Radoslavov

Reputation: 96

You can try ModuleBuilderManager.GetManager().Provider.GetDynamicModuleTypes() to iterate over content types.

Also ModuleBuilderManager.GetManager().Provider.GetDynamicModuleFields() will return all fields of the content types and you can filter by parent and get what you need.

For instance:

var field = ModuleBuilderManager.GetManager().Provider.GetDynamicModuleFields().Where(field => field.ParentTypeId == contentTypeId && field.SpecialType == FieldSpecialType.None && field.Name == fieldName)

Hope this helps!

Upvotes: 0

SelAromDotNet
SelAromDotNet

Reputation: 4815

if you go to the module settings there is a link for "Code Reference" on the right, here are complete code samples that you can copy and paste for interacting with the dynamic module data.

It shows you how to retrieve a collection, and from there you can simply iterate ove that collection, and get values using the GetValue() extension method.

You might also find this blog post useful: http://www.sitefinity.com/blogs/joshmorales/posts/josh-morales-blog/2012/01/19/retrieving_data_from_dynamic_modules_using_the_module_builder_api

hope this helps!

Upvotes: 1

Related Questions