London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Listing all properties on page

Vote:
 

I am having a bit of trouble in listing all properties within a page. By "all" I mean those withing blocks within content areas too. Actually those within blocks which are within blocks, within content area.

Now this is where I get stuck. I get all referenced items in a content area:

var contentArea = (ContentArea)property.Value;
IList<Guid> contentReferences = contentArea.ReferencedPermanentLinkIds;

    

Then I fetch each referenced content item by Guid:

foreach (var contentRef in contentReferences)
{
  var content = repository.Get<IContent>(contentRef, new LanguageSelector(languageId));

  ...
}

    

Now there I get stuck because I should be able to check if content is BlockData or some other type. What I get is a proxy from Castle. If somebody knows what to use with repository.Get<...> or some other way please share.

 

#65249
Jan 23, 2013 16:59
Vote:
 

I tried to use <ContentData> instead of <IContent> when getting a content, but still result is of Castle proxy class.

Addition, repository in second code block in first post is actually:

IContentRepository repository = ServiceLocator.Current.GetInstance<IContentRepository>();

    

#65250
Edited, Jan 23, 2013 17:22
Vote:
 

Hi,

content is BlockData

Will tell you wether it's a block or not. The proxy class inherits the original block class.

Also, you can do

contentArea.Contents

To retrieve the content referenced in the content area directly. 

 

#65253
Edited, Jan 23, 2013 20:11
Vote:
 

Thank you. As .Contents returns the first level content is there some method that can return all content below recursively, something like GetChildren down to bottom or some level?

#65286
Jan 24, 2013 16:05
Vote:
 

I don't think so. There are such functionality in EPiServer Find's API and maybe/probably in EPiServer Search's as well, but I don't think there's any such public method in the CMS' API.

#65294
Jan 24, 2013 22:16
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.