The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
The main reason of this post is a discussion that I had in Sitefinity's forum post. So, the problem here is that you have BlogPosts control that supports filtering, but the same does not apply for CategoriesTree control. Using BlogPosts FilterExpression property you can show only a specific blog posts or group of blog posts instead of all blogs and posts from your provider. So far so good. The main problem comes here. When you drop CategoriesTree built-in control on a page and set ProviderName property, the CategoriesTree control is bound to all categories for this provider instead of categories related to your filtered list of blogs only. I managed to come up with a simple solution that requires creating a custom control that derives from CategoriesTree, implementing a simple property and overriding one method - BindCategories.
1. The property - I will implement a simple property of type Guid which will be used to return the ID of selected blogs. These blogs should be the same as those one listed in BlogPosts control
2. Override LayoutTemplatePath property - we will "map" the external template for CategoriesTree which will allow to make some modifications in RadTreeView declaration.
3. Override BindCategories() method.
- here I check whether there is a value set for our property SelectedBlog. If there is no value I call the base and do not change anything. If there is a value set, I proceed with our custom logic.
- Get the blogs by IDs.
- Get all posts from our blogs
- get metadata - Category for IContent object
- create a new generic list of type ICategory
- add all matches to this list
- bind RadTreeView control to our custom list
- subscribe for NodeDataBound of RadTreeView control to set the node.NavigateUrl property.
The full code is shown below:
View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Subscribe to get all the news, info and tutorials you need to build better business apps and sites
Copyright © 2019 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.