Multiple Classifications and Dynamic Modul
I've added a couple of classifications and added the Category Widget (modifying to use the custom classifications) to my page.
They works fine, but I want them to work together.
For example I have Type (For Sale, For Rent) and also Branch (Manchester, London, etc).
When I click For Sales, then click London, I want to see all the properties For Sale in London? How do I achieve this?
Hello David,
In order to achieve your needs you can extend the master list view of your type by overriding the InitializeListView method and filter the Items list by the filter you need. For example for News
using System;
using System.Collections.Generic;
using System.Linq;
using Telerik.Sitefinity.Data.Linq.Dynamic;
using System.Web;
namespace SitefinityWebApp
public class CustomNewsMasterListView : Telerik.Sitefinity.Modules.News.Web.UI.MasterListView
protected override void InitializeListView(IQueryable<
Telerik.Sitefinity.News.Model.NewsItem
> query, int? totalCount)
// Implement your logic to filter the News Items list in 'query'
string contentFilter = "Visible = true AND Status = Live AND Category.Contains(\"Taxonomy ID\")";
var newQuery = query.Where(contentFilter);
base.InitializeListView(newQuery, totalCount);
Thanks Svetoslav,
Is there a simple way to set the filter expression in the view using the advance dialog box? i.e. Visible = true AND Status = Live AND MyClassification.Contains("Taxonomy ID of selected taxa in Category Widget?") AND MySecondClassifcation.Contains("Taxonomy ID of selected taxa in Category Widget), or am I barking up the wrong tree?
I guess what I am asking is, is there an expression to find out what the selected taxa currently is from the Categories Widget and using this in a filter expression?
Hello David,
Thank you for getting back to me.
Yes you can set such filter expression directly in the widget. To do so for example for News:
Drop the News widget on a Page, than select:
Edit > Advanced > ControlDefinition > Views > NewsFrontendList > FilterExpression, and set in the field the filter you need. Save the changes and publish the Page (screenshot)
This is the "static" filtering approach (set a static filter for that widget). In case you need to do this dynamically (user to be able to choose on the frontend) you need to implement your custom logic extending the widget, as discussed in my previous reply.
Please do not hesitate to let me know if any further questions occur, or you need any additional information. I'll be glad to help you.
Regards,
Svetoslav Manchev
Telerik
Thanks Svetoslav,
It's a shame the Categories widget doesn't support multiple selections, is there a feature request for this? I can image a lot of people will be writing the exact same code thousands of times doing something with data that we all probably need to do in our project. If we had a built in control to do this, we could all spend more time in the pub.
Hello David,
There is such feature request logged in our Feedback portal, where you can vote for it.
Regards,
Svetoslav Manchev
Telerik
Done, Thanks.