Display ContenBlock by category - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Display ContenBlock by category

  • Display ContenBlock by category
  • Hi

    Can anyone help me, on how to display content blocks by category, using the Categories Widget. It's possible width images, docs. blogs and so on, but wath about content blocks??

    Is there another aproach ?? :-)

    Best regards
  • Hello,

    The categories widget is not working with Content Blocks. For performance reasons we have tried minimizing the amount of data being pulled in our ContentSelectors throughout Sitefintiy. Loading all the avaialble tags and categories and filtering by them woul impose slower loading of the data in general.

    If you want you could pull all content blocks filtered by specific tag/category in a custom widget programatically. For example:

    var manager = ContentManager.GetManager();
        var myBlocks = manager.GetContent().Where(contBlock => contBlock.Status == ContentLifecycleStatus.Live && contBlock.GetValue<TrackedList<Guid>>("Tags").Contains(singleGuid));

    where singleGuid is the ID of your tag to filter by. To use the above sample you'll need to add a using Telerik.Sitefinity.Model in your class, to be able to use the extension method GetValue<T>().

    In a nutshell this would allow you to bind a filtered collection of shared content blocks to any suitable control and display the actual HTML content.

    Stefani Tacheva
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • Hello Stefani

    Thank's for your reply.

    In the meantime i have tried to create a module and by the categories widget sorte by dynamic content type. That approach almost work - but how do i get the widget to display content, not only in top level categories??

    Hope there is a solution for that :-)

    Second question - regarding Responsive Design :

    On  the default group of rules i have applyed a css file to modify the layout. But the css file overwrite the default css file and apply the mobile css styles on all devices.. Could you help on that matter to ???

    Look forward to your reply :-)

    Best regards Christian