volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

Get Block data on view

Hi,

I'm using EPiServer 7.5 MVC. I have a view for my page with a content area. I need to get the datas of block(which comes inside content area) on my page(view). Is it possible?

#82438
Mar 12, 2014 11:52

Try this:

@{
    var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
    if (page != null && page.ContentArea != null && page.ContentArea.Items.Any())
    {
        foreach (var contentItem in page.ContentArea.Items)
        {
            var item = contentLoader.Get<YOUR_CONTENT_TYPE>(contentItem.ContentLink);          
            // output necessary properties from content instance
        }
    }
}

    

#82458
Mar 12, 2014 21:04
* 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.