+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Display only Events in specific categories

Display only Events in specific categories

10 posts, 1 answered
  1. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    19 May 2010
    Link to this post
    Is there a way to restrict the Events view control to only show events from a certain category? In News this functionality is pretty much present and I find it kinda neat. Thanks, as always. :)
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    19 May 2010
    Link to this post
    Hello jkregala,

    Thank you for using our services.

    The Events View control does support filtering of Event items based on the category they are assigned to. You can open the Events View control for edit and go to Advanced -> Filters there in the filer expression you can add something like the bellow filter expression which will filter for events belonging to the selected categories:
    Publication_Date <= "#now" AND Expiration_Date > "#now" AND Category IN "Category1,Category2"

    You can also do one little customization - customize the Events View designer so that it has the categories selector for events. You need to edit the control template ~/Sitefinity/Admin/ControlTemplates/Events/EventsViewControlDesigner.ascx. For more information on working with control templates please check here. I have attached all the necessary files. You just have to add this archive to your website. Note you will have to restart the website in order for the changes to take effect. If you already have mapped control templates in controls config file in ~/App_Data/Configuration you have to merge your file with the one I am sending you.

    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Answered
  3. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    19 May 2010
    Link to this post
    Thank you sir! :)
  4. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    19 May 2010
    Link to this post
    Just one tiny follow up question, can I have more than 1 <viewSettings> in my configuration file? I have an existing one for News View, how do I integrate this one with that? Thanks.
  5. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    19 May 2010
    Link to this post
    Hi jkregala,

    Yes, this is the purpose of the controls config file - you can map the Sitefinity controls to your custom control templates.

    Regards,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    19 May 2010
    Link to this post
    Many thanks! :)
  7. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    16 Dec 2010
    Link to this post
    Hi,

    I have followed this thread and have customised the Events View Control Designer as suggested, within my code how do i get at the Categories that were selected? There is a property called SelectedCategories but that crashes out every time with "Object not set to reference....."

    Any ideas?

    Thanks
    higgsy
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 Dec 2010
    Link to this post
    Hello higgsy,

    Most probably you are not getting the property correctly. Inside the control designer, CreateChildControls you should be able to call this.Selector.SelectedValues. Another option is accessing the FilterExpression property of the control through the ControlDesigner

    ((EventsView)DesignedControl).FilterExpression

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    16 Dec 2010
    Link to this post
    Hi Ivan,

    I'm not sure I explained myself properly. Im not within the control designer, as the control designer is the built-in eventsview control designer. Radoslav suggested:

    You can also do one little customization - customize the Events View designer so that it has the categories selector for events. You need to edit the control template~/Sitefinity/Admin/ControlTemplates/Events/EventsViewControlDesigner.ascx

    Now, when I launch the ControlDesigner for my EventsView control I can select which Categories I want to be displayed. But how can I programmatically get the Selected Categories property from my EventsView control.

    If you are suggesting I need to create a Custom Control Designer that inherits from the EventsViewControlDesigner then that that is one thing, but it must be possible to get the Selected Categories property from the EventsView because it has an impact on the results which are shown. I tried using the SelectedCategories propeerty but this obselete, and crashed.

    Thanks
    higgsy
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 Dec 2010
    Link to this post
    Hello higgsy,

    The control does not have direct reference to the control designer. The relation is ControlDesigner -> Control.
    You can use the FilterExpression property which should be set if you use CategoriesList control.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
10 posts, 1 answered