November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
The PropertyData has a property called Value which generally is an object so you need to cast it.
How about something like this? It's a short way to get your property values and check if they are ContentAreas
IEnumerable<BlockData> blocks = GetBlocks(); foreach (var block in blocks) { var properties = block.Property; foreach (var key in properties.Keys) { var contentArea = properties[key].Value as ContentArea; if(contentArea != null) { var items = contentArea.Items; // Or use FilteredItems foreach (var item in items) { var contentLink = item.ContentLink; // Get Content and start over. Preferably with some nested functionality } } } }
Though if you want to see references between content there are other ways.
I would like to query blocks to see if they have any content areas, and then loop through any items in the content areas.
At the moment I have a webform (its an MVC site - the webform is just for staging/dev environment) that lists all the pages on the site, as well as all the blocks within "MainContentArea", which is the primary ContentArea in my sites SitePageData. The page allows me at a glance to see where pagetypes and blocktypes have been used.
I would like to be able to interrogate the blocks that i find within the pages contentarea to see if they have any ContentAreas of their own, and then list the blocks therein. However i only seem to be able to get a list of the properties:
foreach(var y in blk.Property) {
if("EPiServer.SpecializedProperties.PropertyContentArea" == y.GetOriginalType().ToString()) {
But i dont know how to get the actual ContentArea from the stated property.
Can anyone enlighten me?
Marshall