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

Forums / Designing with Sitefinity / News Archive Filtering Interfering with Blog Listings

News Archive Filtering Interfering with Blog Listings

8 posts, 1 answered
  1. VectorLord
    VectorLord avatar
    24 posts
    Registered:
    28 Sep 2009
    10 Dec 2009
    Link to this post
    Hi,

    My home page has a news list, a news archive in tree view mode, and two blog listings. The news list shows the most recent 8 items and will show a maximum of 24 paged items. The news paging control displays its results on the same page. The two blog listings only show the last item entered into each blog (one is for the word translation of the day, and the other is for the joke of the day). There is a news archive control in the right column of the page for the news listing.

    I'm experiencing two problems with this arrangement:

    1. I have news articles entered with December and November publication dates (although, all were created in December - we have a LOT of archives to recreate), but the news archive control is only showing "December 2009" in the treeview control. When I click on Dec 2009 in the treeview, the November articles disappear. I can manually make them reappear by changing the query string to "Month=11," but I can't do this using the treeview. What are the possible reasons why November is not showing up?

    2. When I change the query string Month to 11, my word and joke of the day disappear (because I have none published for November). I only want the last item entered to appear in these blogs and I do not want them to be affected by the News Archive control. Is there a way to prevent the query string from affecting these blog listings? I'm restricting them using the 3rd step of the Blog Posts requester by setting the maximum item limit to 1 and turning OFF paging. Is there a better way of displaying the single, most recent item that would also avoid the query string filtering?

    Thank you to anyone who can help with this!
  2. VectorLord
    VectorLord avatar
    24 posts
    Registered:
    28 Sep 2009
    10 Dec 2009
    Link to this post
    Update:

    Well, I somehow briefly solved one of the problems. I was playing around with the News Archive control Advanced > Behavior > Archive Span property, changing it from the default "All" to "Three Years," and suddenly November started showing up. I switched it back to "All," and it's still there.

    However, I tried to duplicate this behavior by adding a single entry for October, but failed in all attempts to have it show up in the treeview or the dropdownlist mode.

    Could this be a bug? Any ideas?
  3. VectorLord
    VectorLord avatar
    24 posts
    Registered:
    28 Sep 2009
    10 Dec 2009
    Link to this post
    Update 2:

    I added a second news item for October, refreshed the page, and October 2009 still didn't show up in the dropdownlist. I changed the Archive Span property in the News Archive control from Three Years to All again and October 2009 began showing up in the dropdownlist mode. ???
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Dec 2009
    Link to this post
    Hi VectorLord,

    By default the NewsArchive caches for about 24 hours or until the application is restarted. This could be the reason of the behavior you see.


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. VectorLord
    VectorLord avatar
    24 posts
    Registered:
    28 Sep 2009
    11 Dec 2009
    Link to this post
    Thanks, Ivan.

    I actually solved this late yesterday by adding the following string to the filter property:

    Publication_Date >= "01/01/1990 12:00:00 AM"

    This had an immediate effect, and when I added an article for another month, the news archive instantly updated.

    So, any ideas on how to solve problem number 2 in my first post? Would adding a filter to those blog listings force them to display the latest post and override the query strings? What would the syntax look like for such a filter?
  6. VectorLord
    VectorLord avatar
    24 posts
    Registered:
    28 Sep 2009
    15 Dec 2009
    Link to this post
    Ivan,
        Any ideas on how to solve problem 2 in the original post above?
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Dec 2009
    Link to this post
    Hi VectorLord,

    When I change the query string Month to 11, my word and joke of the day disappear (because I have none published for November). I only want the last item entered to appear in these blogs and I do not want them to be affected by the News Archive control. Is there a way to prevent the query string from affecting these blog listings? I'm restricting them using the 3rd step of the Blog Posts requester by setting the maximum item limit to 1 and turning OFF paging. Is there a better way of displaying the single, most recent item that would also avoid the query string filtering?

    You have to create a custom class that inherits from NewsView. Then override CreateChildControls method. Sample code is shown below:

        protected override void CreateChildControls()
        {
          
            if (!String.IsNullOrEmpty(Context.Request["Year"]))
            {
             int year = int.Parse(Context.Request["Year"]);
             if (!String.IsNullOrEmpty(Context.Request["Month"]))
             {
                 int month = int.Parse(Context.Request["Month"]);
                 ContentManager manager = new ContentManager("News");
                 List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>();
                 filter.Add(new MetaSearchInfo(MetaValueTypes.DateTime, "Publication_Date", new DateTime(year, month, 1, 0, 0, 0).ToString(), SearchCondition.GreaterOrEqual, JoinType.And));
                 filter.Add(new MetaSearchInfo(MetaValueTypes.DateTime, "Publication_Date", new DateTime(year, month, DateTime.DaysInMonth(year, month), 23, 59, 59).ToString(), SearchCondition.LessOrEqual, JoinType.And));
                 IList contentItems = manager.GetContent(filter.ToArray());
                 if (contentItems.Count > 0)
                 {
                     base.CreateChildControls();
                 }
                 else
                 {
                            // add logic to show only single item.
                     this.ItemsPerPage = 1;
                     this.AllowPaging = true;
                     this.SortExpression = "Publication_Date DESC"
                     base.CreateChildControls();
             
                     
                 }
             }
          }
    }


    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
  8. VectorLord
    VectorLord avatar
    24 posts
    Registered:
    28 Sep 2009
    21 Jan 2010
    Link to this post
    I can see how that would work; however, we ended up changing the design (for other reasons) to open the archives on a separate page and eliminate the archive control in the right margin. This approach solved multiple technical and design issues for us. Thanks so much for your help!
Register for webinar
8 posts, 1 answered