How to get category from block in cshtml view?

Vote:
 

In my block, authors have the ability to add categories. How do i access this in the cshtml/view page?

Tried. Model.CurrentBlock. ...but it doesn't have any "category" property.

#266740
Nov 15, 2021 2:40
Vote:
 

The ICategorizable interface although implemented implicitly in PageData isn't implemented for BlockData as blocks can be used not only as page components for as shared properties areas. Therefore they are composed at runtime via Castle Winsor Proxies.

To gain access to a block's Category propery simple cast it to ICategorizable such as

var categoryCurrentBlock = (ICategorizable)currentBlock;

Although I would recommend doing things like this in a Controller and passing a ViewModel to the cshtml file.

#266744
Edited, Nov 15, 2021 9:01
kingofeverything131 - Nov 18, 2021 6:20
This works, however, how do I get the category name from here?

Right now it’s just returning a list. And all I can see is the count
This thread is locked and should be used for reference only.
* 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.