Filtering with Custom Classification
Hi All,
I'm trying to figure out how to filter items from a custom module with custom classifications. Can I use the filter expression under advanced settings in the item widget or do I need to create a custom control?
Thanks,
Jason
Hello Jason,
Yes, you can modify the default FilterExpression in the Advanced settings to filter by custom classification as well, what you need to do is extend the default filter by adding
"AND" + "YourCustomFieldName" and then you can use .Contains filter, by passing the taxon id like this:
Visible = true AND Status = Live AND Cat2.Contains((FF11D5C7-8016-4558-9DFE-91169288F0AB))public IEnumerable<Document> GetDocumentsByCategoryOrTag(string libraryName, string categoryName, string tagName) var manager = TaxonomyManager.GetManager(); var docManager = LibrariesManager.GetManager(); //Get the GUID of the desired category var myCategoryId = manager.GetTaxa<HierarchicalTaxon>().Where(t => t.Name == categoryName).SingleOrDefault().Id; //Alternatively you can get the GUID of the desired Tag var myTagId = manager.GetTaxa<FlatTaxon>().Where(t => t.Name == tagName).SingleOrDefault().Id; //get documents by Library var docList = docManager.GetDocuments().Where(d => d.Parent.Title == libraryName); //Get a list of the news items who have the desired category assigned to them var docListByCats = docList.Where(d => d.GetValue<TrackedList<Guid>>("Category").Contains(myCategoryId)); //Or by Tags var docListByTags = docList.Where(d => d.GetValue<TrackedList<Guid>>("Tags").Contains(myTagId)); return docListByCats; //or // return docListByTags; Hi Boyan, Im currently trying to filter Ecommerce products with custom classifications by using your solution however Im getting object reference not set error. What I am trying to achieve is adding a list of vendor to choose from when uploading a product and on separate pages have the ecommerce product list widget display the list of product from each vendor. I have attached some screenshots for reference.
Any help?