Get block type data

Hi all,

I have a block with name market.

i have another block ads, in that block i want to display market block data.

so how can i achive this using c# backend code not browser.

Edited, Jan 24, 2017 6:07
  • Hi Sandeep,

    From what I could understand in Second block you want to show MarketBlock? If that is a case in Second block you need "ContentArea" as below:

    public virtual ContentArea Market {get;set;}

    And admin can drag and drop an instance of the Market block into that Second block content area you created. Other, way is to have Market block property as below:

    public virtual Market Market {get;set;}

    That means per each Second block  instance you will have an instance of  Marke means you can't re-use.

    Aria

    Jan 24, 2017 7:03
  • i want c# code for how to get block data

    Jan 24, 2017 7:30
  • if(currentBlock.BlockContentArea != null && currentBlock.BlockContentArea.Items.Any())

    {

                     foreach (var contentItem in currentBlock.BlockContentArea.Items)
                    {

    var contentLoader =   ServiceLocator.Current.GetInstance<IContentLoader>();
     var contentOfBlock = contentLoader.Get<IContentData>(contentItem.ContentLink) 

                    }

    }

    Jan 24, 2017 9:08
  • hi here what is BlockContentArea, and how to declare it. could u provide sample code snippet,

    how can i get perticular block type data( my requirement is market).

    thnaks in advance

    Edited, Jan 24, 2017 17:25
  • can you please give me your properties and what is a requirement?

    Jan 25, 2017 7:10
First   1   Last