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

Forums / Bugs & Issues / Blog and Calendar filtering

Blog and Calendar filtering

9 posts, 1 answered
  1. Luke Horan
    Luke Horan avatar
    20 posts
    Registered:
    02 May 2010
    15 Sep 2010
    Link to this post
    Hi Guys,

    I'm developing a site in 3.7 and I'm trying to get the calendar control to filter the blog posts when you click on a specific day.
    It only filters by month the month. Is this a bug or by design?

    I can't see any additonal areas in the admin side of the user controls that I can change to get this to work.
    Any ideas?

    Thanks
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Sep 2010
    Link to this post
    Hi Luke Horan,

    BlogCalendar filters by Year. Month and Day. I am sending you a short video prepared over Sitefinity 3.7 SP3.

    Best wishes,
    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
  3. Luke Horan
    Luke Horan avatar
    20 posts
    Registered:
    02 May 2010
    15 Sep 2010
    Link to this post
    Hi Ivan,

    Thanks for the reply but It seems to only work when all blogs are returned but not when a specific blog is selected. If one blog is select then it only filters by month.

    please see
    http://stage.dixon.com.au/test101.aspx?Year=2010&Month=8&Day=3
     for and example of it not working.

    This page is where all blogs are returned and it filters correctly.
    http://stage.dixon.com.au/test102.aspx?Year=2010&Month=8&Day=3
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Sep 2010
    Link to this post
    Hello Luke Horan,

    I found the problem and fix for it. You should create a custom class in App_Code folder as this one shown below and register it as a control in your web.config. Then you should use BlogCalendar control with the custom BlogPostsSitefinityFix .

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Blogs.WebControls;
    using Telerik.Cms.Engine.ContentViewFiltering;
      
    /// <summary>
    /// Summary description for BlogPostsSitefinityFix
    /// </summary>
    public class BlogPostsSitefinityFix : BlogPosts
    {
        public BlogPostsSitefinityFix()
        {
        }
      
        public override string SingleItemTemplatePath
        {
            get
            {
                return "~/Sitefinity/Admin/ControlTemplates/Blogs/Modes/ListPageDetail.ascx";
            }
            set
            {
                base.SingleItemTemplatePath = value;
            }
        }
      
        public override string ItemListTemplatePath
        {
            get
            {
                return "~/Sitefinity/Admin/ControlTemplates/Blogs/Modes/ListPageMaster.ascx";
            }
            set
            {
                base.ItemListTemplatePath = value;
            }
        }
      
        public override Type LocalizationAssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.LocalizationAssemblyInfo = value;
            }
        }
      
        public override Type AssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.AssemblyInfo = value;
            }
        }
      
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
      
            var filterBuilder = new ContentFilterBuilder(this);
            if (!String.IsNullOrEmpty(Context.Request["Year"]))
            {
                int year = int.Parse(Context.Request["Year"]);
                int month = 0;
                if (!String.IsNullOrEmpty(Context.Request["Month"]))
                    month = int.Parse(Context.Request["Month"]);
                int day = 0;
                if (!String.IsNullOrEmpty(Context.Request["Day"]))
                    day = int.Parse(Context.Request["Day"]);
      
                ContentFilterStatement filterStartDate;
                ContentFilterStatement filterEndDate;
      
       
                if (month != null && month >= 1 && month <= 12)
                {
        
                    filterStartDate = new ContentFilterStatement(
                        "Publication_Date",
                        String.Concat("\"", new DateTime(year, month, day, 0, 0, 0).ToString(), "\""),
                        ContentFilter.Condition.GreaterOrEqual,
                        ContentFilter.JoinType.And);
                    filterEndDate = new ContentFilterStatement(
                        "Publication_Date",
                        String.Concat("\"", new DateTime(year, month, day, 23, 59, 59).ToString(), "\""),
                        ContentFilter.Condition.LessOrEqual,
                        ContentFilter.JoinType.And);
                }
                else
                {
                    filterStartDate = new ContentFilterStatement(
                        "Publication_Date",
                        String.Concat("\"", new DateTime(year, 1, 1).ToString(), "\""),
                        ContentFilter.Condition.GreaterOrEqual,
                        ContentFilter.JoinType.And);
                    filterEndDate = new ContentFilterStatement(
                        "Publication_Date",
                        String.Concat("\"", new DateTime(year, 12, DateTime.DaysInMonth(year, 12)).ToString(), "\""),
                        ContentFilter.Condition.LessOrEqual,
                        ContentFilter.JoinType.And);
                }
      
                filterBuilder.RemoveFilter(filterStartDate);
                filterBuilder.RemoveFilter(filterEndDate);
      
                filterBuilder.AddFilter(filterStartDate);
                filterBuilder.AddFilter(filterEndDate);
            }
        }
    }

    <toolboxControls>
        <clear />
         <add name="BlogPostsSitefinityFix" section="Custom" type="BlogPostsSitefinityFix, App_Code"/>

    Control templates and BlogPostsSitefinityFix class are attached.

    Greetings,
    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
  5. Luke Horan
    Luke Horan avatar
    20 posts
    Registered:
    02 May 2010
    15 Sep 2010
    Link to this post
    Thanks Ivan but unfortunately it doesn't seem to have fixed the issue.
    Any other ideas?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Sep 2010
    Link to this post
    Hello Luke Horan,

    I am sending you a short video which shows how the control works and that all posts are filtered correctly.

    Kind regards,
    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
  7. Luke Horan
    Luke Horan avatar
    20 posts
    Registered:
    02 May 2010
    15 Sep 2010
    Link to this post
    Hi Ivan,
    can you double check that  test with more than 1 date in september than just the 15th, as it seems to filter by month not month and day.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Sep 2010
    Link to this post
    Hi Luke Horan,

    Ok I slightly modified the code, but it will be better if you provide full description on the issue and how it can be reproduced, so I will not loop and debug each method trying to figure out in which scenario I could get to the point and you will get a solution faster. Now the code should work fine in the following circumstances

    1. You have a single blog selected
    2. You have several posts per day in a  month.

    here is the code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Blogs.WebControls;
    using Telerik.Cms.Engine.ContentViewFiltering;
    using Telerik.Cms.Engine;
     
    /// <summary>
    /// Summary description for BlogPostsSitefinityFix
    /// </summary>
    public class BlogPostsSitefinityFix : BlogPosts
    {
        public BlogPostsSitefinityFix()
        {
        }
     
        public override string SingleItemTemplatePath
        {
            get
            {
                return "~/Sitefinity/Admin/ControlTemplates/Blogs/Modes/ListPageDetail.ascx";
            }
            set
            {
                base.SingleItemTemplatePath = value;
            }
        }
     
        public override string ItemListTemplatePath
        {
            get
            {
                return "~/Sitefinity/Admin/ControlTemplates/Blogs/Modes/ListPageMaster.ascx";
            }
            set
            {
                base.ItemListTemplatePath = value;
            }
        }
     
        public override Type LocalizationAssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.LocalizationAssemblyInfo = value;
            }
        }
     
        public override Type AssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.AssemblyInfo = value;
            }
        }
     
        protected override System.Collections.IList CreateDataSource()
        {
            var filterBuilder = new ContentFilterBuilder(this);
            if (!String.IsNullOrEmpty(Context.Request["Year"]))
            {
                int year = int.Parse(Context.Request["Year"]);
                int month = 0;
                if (!String.IsNullOrEmpty(Context.Request["Month"]))
                    month = int.Parse(Context.Request["Month"]);
                int day = 0;
                if (!String.IsNullOrEmpty(Context.Request["Day"]))
                    day = int.Parse(Context.Request["Day"]);
     
                ContentFilterStatement filterStartDate;
                ContentFilterStatement filterEndDate;
     
     
                if (month != null && month >= 1 && month <= 12)
                {
     
                    filterStartDate = new ContentFilterStatement(
                        "Publication_Date",
                        String.Concat("\"", new DateTime(year, month, day, 0, 0, 0).ToString(), "\""),
                        ContentFilter.Condition.GreaterOrEqual,
                        ContentFilter.JoinType.And);
                    filterEndDate = new ContentFilterStatement(
                        "Publication_Date",
                        String.Concat("\"", new DateTime(year, month, day, 23, 59, 59).ToString(), "\""),
                        ContentFilter.Condition.LessOrEqual,
                        ContentFilter.JoinType.And);
                }
                else
                {
                    filterStartDate = new ContentFilterStatement(
                        "Publication_Date",
                        String.Concat("\"", new DateTime(year, 1, 1).ToString(), "\""),
                        ContentFilter.Condition.GreaterOrEqual,
                        ContentFilter.JoinType.And);
                    filterEndDate = new ContentFilterStatement(
                        "Publication_Date",
                        String.Concat("\"", new DateTime(year, 12, DateTime.DaysInMonth(year, 12)).ToString(), "\""),
                        ContentFilter.Condition.LessOrEqual,
                        ContentFilter.JoinType.And);
                }
     
                filterBuilder.RemoveFilter(filterStartDate);
                filterBuilder.RemoveFilter(filterEndDate);
     
                filterBuilder.AddFilter(filterStartDate);
                filterBuilder.AddFilter(filterEndDate);
            }
                return Manager.GetContent(GetContentStartIndex(), GetPageSize(), SortExpression,
                                          filterBuilder.ParseTagFilter(), ContentStatus.Published, null,
                                          filterBuilder.ParseParentsFilter(), filterBuilder.ParseMetaFieldsFilter());
        }
    }


    video has been attached.

    Kind regards,
    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
    Answered
  9. Luke Horan
    Luke Horan avatar
    20 posts
    Registered:
    02 May 2010
    16 Sep 2010
    Link to this post
    Thanks Ivan, That fixed the problem.
    Much appreciated.
Register for webinar
9 posts, 1 answered