Option 1 is to take control of the rendering of content area yourself. You can use the ContentArea.Items collection for this:
@{ var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>(); if (page != null && page.ContentArea != null && page.ContentArea.FilteredItems.Any()) { foreach (var contentItem in page.ContentArea.FilteredItems) { var item = contentLoader.Get<INSERT CONTENT TYPE>(contentItem.ContentLink); //print your properties... } } }
Option 2 is to use javascript to simply hide the ones you don't want to show. And then let button trigger to show 6 more. Easier but might be a performance issue if you have really many. I would go for this one normally since it's rare you have enough blocks that this would actually be a real problem.
Thanks Daniel!
But I getting this error:
The name 'Locate' does not exist in the current contex
Is there any namespace required for Locate? What Is that?
Thanks!
Locate is a shortcut property that is available on some classes that is used to fetch instances of services. You can also use the ServiceLocator for that directly as well (like above) and that is in the
EPiServer.ServiceLocation
namespace.
I need to display a block on a page. For the very first time when page load, only 6 blocks should be displayed by default. And there is a "Load More" button on that page, once user click on this button the next 6 more blocks should be displayed and so on.