Multiple Classifications and Dynamic Modul - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Multiple Classifications and Dynamic Modul

  • 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);
            
        

    The filter classification could be added on the page using some dropdown lists, checkboxes or any other control to list your classifications.

    Additional information how to extend the view is available here:
    http://www.sitefinity.com/blogs/stanislav-velikovs-blog/2012/01/23/how_to_add_additional_logic_into_sitefinity_built_in_widgets

    Information about content filters can be found here:
    http://docs.sitefinity.com/filter-expressions-for-content-items
    http://docs.sitefinity.com/for-developers-filter-dynamic-content-items-by-dynamic-field

    I hope this information helps.

    Regards,
    Svetoslav Manchev
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  • 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?

  • 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,

    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
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  • Hello David,

    There is such feature request logged in our Feedback portal, where you can vote for it.

    Regards,
    Svetoslav Manchev
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  • Done, Thanks.