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

Forums / General Discussions / Blog Categories & Archives

Blog Categories & Archives

13 posts, 0 answered
  1. Brian
    Brian avatar
    31 posts
    Registered:
    25 Jun 2009
    23 Mar 2011
    Link to this post
    I have 3 blogs setup in Sitefinity 4.0 for a client.  I'm using the Category & Archive widget to display the categories & archives.  I've used the Content Type of Telerik.Sitefinity.Blogs.Model.BlogPost. 

    Problem is the category & archive widgets are showing all of the blog categories & archives.  How can I have each blog only display it's own categories & archives?

    Thanks,

    Brian
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 Mar 2011
    Link to this post
    Hello Brian,

    There is no implementation out of the box that you can use to achieve your goal. I logged a task with ID 111360 in our internal system and on the next planning we are going to discuss if we will be able to implement a property that allows you filtering by parent ID. Then we will add the task to PITS so you can use the ID I gave you to monitor the status. There is a way to filter by parent in a custom control that inherits from

    Telerik.Sitefinity.Web.UI.PublicControls.ArchiveControl

    There is a virtual method ConstructArchiveItems which you can override and filter the items returned by

    var items = manager.GetArchieveItems(contentType, this.Provider, this.DateBuildOptions, this.DateEvaluatorPropertyName);

    Kind regards,
    Ivan Dimitrov
    the Telerik team
  3. Brian
    Brian avatar
    31 posts
    Registered:
    25 Jun 2009
    24 Mar 2011
    Link to this post
    Ivan,

    Would you be able to provide me with a custom control example for filtering out blog categories & archives based on the different blogs? 

    I really have no idea how to get this working & am kinda in a crunch to get this fixed.

    Thanks for any help you can provide!

    Brian
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Mar 2011
    Link to this post
    Hi Brian,

    Here is a sample code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Telerik.Sitefinity.Web.UI.PublicControls;
    using System.Web.UI.WebControls;
    using Telerik.Sitefinity.Web.UrlEvaluation;
    using System.Web.UI;
    using Telerik.Sitefinity.Modules.GenericContent;
    using Telerik.Sitefinity.Utilities.TypeConverters;
     
     
    namespace Telerik.Sitefinity.Samples
    {
        public class ArchiveControlCustom : ArchiveControl
        {
     
            protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container)
            {
     
                RenderTitle();
                this.dateRangeValues = GetDateRangeValues();
                ConstructArchiveItems();
                     
            }
     
     
            protected virtual void ConstructArchiveItems()
            {
                var manager = ContentManager.GetManager();
                if (this.ContentType != null)
                {
                    var contentType = ResolveContentType();
     
                    // here get the items you need and bind the repeater control that will show only single blog items
                    var items = manager.GetArchieveItems(contentType, this.Provider, this.DateBuildOptions, this.DateEvaluatorPropertyName);
                     
                }
            }
     
            internal virtual Type ResolveContentType()
            {
                var contentType = TypeResolutionService.ResolveType(this.ContentType);
                if (contentType == null)
                {
                    throw new ArgumentException(String.Format("Content type \"{0}\" cannot be resolved.", this.ContentType));
                }
                return contentType;
     
            }
     
     
            internal bool IsDateInRange(DateTime t)
            {
                var result = false;
                if (this.dateRangeValues.Count > 0)
                {
                    var from = dateRangeValues[0];
                    var to = dateRangeValues[1];
     
                    result = t.IsDateInRange(from, to);
                }
                return result;
            }
     
            internal virtual void RenderTitle()
            {
                var placehodler = this.Container.GetControl<PlaceHolder>("plhTitle", false);
                if (!String.IsNullOrEmpty(this.Title))
                {
                    placehodler.Visible = true;
                    TitleLabel.Text = this.Title;
                }
                else
                {
                    placehodler.Visible = false;
                }
            }
     
            internal virtual List<DateTime> GetDateRangeValues()
            {
                var evaluator = UrlEvaluator.GetEvaluator("Date");
                var values = new List<DateTime>();
                if (!this.IsDesignMode())
                {
                    var url = this.Page.Request.Url.AbsolutePath;
                    (evaluator as DateEvaluator).Evaluate(url, this.DateEvaluatorPropertyName, this.GetUrlEvaluationMode(), this.UrlKeyPrefix, out values);
                }
                return values;
            }
     
            private List<DateTime> dateRangeValues;
        }
    }


    Greetings,
    Ivan Dimitrov
    the Telerik team
  5. David Bruce Muir
    David Bruce Muir avatar
    15 posts
    Registered:
    07 Nov 2008
    15 Dec 2011
    Link to this post
    I too would appreciate to have this functionality included in the next build of SF.  One of my sites has 'public' content as well as 'secure' content contained within 2 separate blogs.  I'd like to categorize posts within each and not have 'secure' content included within the 'public' category list and visa versa.
  6. Hristo Borisov
    Hristo Borisov avatar
    190 posts
    Registered:
    18 Nov 2016
    21 Dec 2011
    Link to this post
    Hello David Muir,

    You can create a new classification in the system by visiting the Content-> All Classifications options. Once you create the classification you want, you can create a custom field in the blog posts that let's you choose your private/public classification hierarchy. As for the public side, you can drop the Categories widget and show only the classification you want.

    Please let me know if you have any difficulties applying the example above for your scenario.

    Regards,
    Hristo Borisov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  7. David Bruce Muir
    David Bruce Muir avatar
    15 posts
    Registered:
    07 Nov 2008
    21 Dec 2011
    Link to this post
    Thank you very much for your assistance!  But I have a couple questions, still:

    You said #1: Once you create the classification you want, you can create a custom field in the blog posts that let's you choose your private/public classification hierarchy.

    My Response to #1: I've created the new 'secure categories' classification.  But I'm wanting to use it exactly as I do the default Sitefinity classification on the public side.  Please see this example: http://www.apexalternativestrategies.com/education

    More specifically, I'd like to be able to add one (or more) of these new 'secure categories' to each of my secure blog posts as I create the blog post using the default Sitefinity 'Create a post' feature.

    My First Question to #1: How do I do this?  If it's by creating a custom field in the blog post, where can I read more on how to do this?

    And then, I would like to drop my new 'secure categories' classification onto my secure blog post page and have it work exactly as the public blog post page classification "filter" does on the example link I sent.

    My Second Question to #1:  What's the best way to do this?  Should I create a new custom user control?  If so, where can I get the code of the Sitefinity default classification user control so that I can modify it accordingly?

    You said #2: As for the public side, you can drop the Categories widget and show only the classification you want.

    My Response to #2: This is exactly what I had already done, as you see in the example link I sent.  :)

    THANKS AGAIN!
  8. Liz
    Liz avatar
    13 posts
    Registered:
    01 Mar 2011
    04 Jan 2012
    Link to this post
    Hi Ivan,

    Has this been added to PITS?  I tried searching for id  111360 and ArchiveControl, but did not find a corresponding item.

    Thanks!

    Liz
  9. Hristo Borisov
    Hristo Borisov avatar
    190 posts
    Registered:
    18 Nov 2016
    11 Jan 2012
    Link to this post
    Hi Brian,

    Please excuse us for the prolonged response, but we have been considering the priorities of this feature. The scenario you talk about is dependent on a couple of features that we currently lack. We have scheduled the following functionality for Sitefinity 5.1:

    • Dedicated widget that can show custom taxonomies on the public site, so that website visitors can filter your content based on a custom taxonomy
    • Modify all selectors of Sitefinity to include an option to select custom taxonomy, so that Sitefinity users can show  content based on a custom taxonomy.

    Thank you for contacting us and raising the priority of this feature, we will do our best to include this feature with some of our internal builds prior the Sitefinity 5.1 release.

    Kind regards,
    Hristo Borisov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  10. KMac
    KMac avatar
    133 posts
    Registered:
    15 Dec 2008
    04 Oct 2012
    Link to this post
    Hello, just curious as to when these items will be implemented. It mentions 5.1 but I don't see the option in the Sitefinity selectors to choose custom taxonomies yet. Is it now planned for 5.2?

    Thanks
  11. KMac
    KMac avatar
    133 posts
    Registered:
    15 Dec 2008
    04 Oct 2012
    Link to this post
    Hello, just curious as to when these items will be implemented. It mentions 5.1 but I don't see the option in the Sitefinity selectors to choose custom taxonomies yet. Is it now planned for 5.2?

    Thanks
  12. Seth
    Seth avatar
    1 posts
    Registered:
    17 Oct 2012
    13 Dec 2012
    Link to this post
    I also need to filter the archive control to specific blogs. 

    I am trying the custom control method as indicated by Ivan but have some questions.

    Do we need to set LayoutTemplateName?

    Also, in the sample code it says to blog posts for on the blog we need.  That means not using the GetArchieveItems() functions anymore?

    Then it says to bind the repeater control, but in the context of a custom control where is this repeater control and how do we reference it?  The default layout will have a repeater already yes? 

    Am I missing something else?

    Thanks ahead of time,
    Eugene
  13. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    17 Dec 2012
    Link to this post
    Hello Eugene,

    You can set to use the default template of the control in your code by calling the base property for the layouttemplate path ( if you want to use the default one ). However, if you want to customize the template as well you can get the template for the archive control from the SDK.

    For your convenience I have created a sample control in which we add another Repeater to the ItemTemplate of the repeater, which displays the dates in the Archive widget. The second repeater lists all news items, depending on their publishing date. You can further modify the initial logic to change the content type and filter it further.

    You can find the template, attached below. To map it in Sitefinity, go to Administration -> Settings -> Advanced -> Controls -> ViewMap and map the template the following way:

    HostType: Telerik.Sitefinity.Web.UI.PublicControls.ArchiveControl
    LayoutTemplatePath: PathToTheTemplate

    Greetings,
    Victor Velev
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
13 posts, 0 answered