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

Forums / Bugs & Issues / Comma in Category causes blog posts to not show

Comma in Category causes blog posts to not show

4 posts, 0 answered
  1. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    29 Apr 2010
    Link to this post
    Hi,

    I found a bug the other day where the associated blog posts will not display in the list view when their category has a comma in it. This is in 3.7 SP3

    To replicate:
    Create a blog post and assign it to a category with a comma in the category name.
    Using the categories list control and BlogPost View control on a page click the category with the comma it.
    No posts will be displayed. Click any other categories and post will be displayed.

    Another bug exists in the categories list control... the count does not work properly when in list mode but is fine in treeview mode. This has been around for a long time.

    Thanks

    Seth
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    29 Apr 2010
    Link to this post
    Hi Seth Cleaver,

    It is not possible to have comma in the name of a category, because the filter splits the string. If you have category called "Test, Test", the filter splits the string to "Test" and "Test" and the value of the right operand of the filter becomes "Test" instead of "Test, Test".

    If you want to use comma in the name of a category you need to override ParseMetaFieldsFilter() virtual method of ContentFilterBuilder class and then implement the filter in a custom control that inherits from BlogPosts.

    sample code.

    protected override IMetaSearchInfo[] ParseMetaFieldsFilter()
          {
              var manager = new ContentManager(filterableControl.ProviderName);
              Dictionary<string, IMetaInfo> metaFields = (Dictionary<string, IMetaInfo>) manager.MetaKeys;
               
              List<IMetaSearchInfo> filters = new List<IMetaSearchInfo>();
              List<IContentFilterStatement> statements = ParseInternal(true);
     
              foreach(IContentFilterStatement statement in statements)
              {
                 
                  if (metaFields.ContainsKey(statement.LeftOperand))
                  {
                       
                      if(statement.Condition == ContentFilter.Condition.In)
                      {
                          foreach(string rightOperandString in rightOperandStrings)
                          {
                              MetaSearchInfo searchInfo = new MetaSearchInfo(metaFields[statement.LeftOperand].ValueType,
                                  statement.LeftOperand, rightOperandString.Trim(), SearchCondition.Equal, JoinType.And);
                              filters.Add(searchInfo);
                          }
                      }
                      else
                      {
                          MetaSearchInfo searchInfo = new MetaSearchInfo(metaFields[statement.LeftOperand].ValueType,
                                                                statement.LeftOperand,
                                                                statement.GetRightOperandWithoutSyntax().Trim(),
                                                               GetMetaSearchCondition(statement.Condition),
                                                                GetMetaJoinType(statement.JoinType));
                          filters.Add(searchInfo);
                      }
                  }
              }
              return filters.ToArray();
          }

    The second problem is result of caching - both controls - CategoryList and CategoryTree use caching and the count is updated when the application is restarted or after 24 hours. There are some bugs with CategoryList control that are not sorted out and I suggest that you should use CategoryTree control instead which works properly.

    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.
  3. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    29 Apr 2010
    Link to this post
    Hi,

    Thanks for the reply. It might be a good idea to consider whether you can support commas in categories in future versions because for a content managers point of view they just think "why can't my categories have a comma".

    On the second point.... nope the problem is not due to caching. The categories list was displaying counts like "19" when there was definitely never that many posts in a category at any point. So I built my own category list control. But please have someone look into it. Both display modes of the category control should be working as it is not a complicated control and has from memory been broken for ages.

    Just another quick question. Has anyone investigated trying to use the url rewriter to have friendly category urls... for example

    /blog/posts.aspx?BlogCatID="Category Name"    rewritten as
    /blog/posts/category name.aspx

    I tried to configure Sitefinity's rewriter to do this but kept getting errors and didn't know whether it was because of other rewriting going on with the BlogPosts content view.

    Thanks

    Seth
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    29 Apr 2010
    Link to this post
    Hello Seth Cleaver,

    "Both display modes of the category control should be working as it is not a complicated control and has from memory been broken for ages".

    The problem was logged some time ago and we will try to fix it.

    The quick question

    /blog/posts.aspx?BlogCatID="Category Name"    rewritten as
    /blog/posts/category name.aspx

    This could not work and it would be not possible to implement it.

    • The link - /blog/posts/category name.aspx will be considered as a regular page and you will get 404. There will be a problem when you work with extensionless urls as well.
    • BlogPosts control relies of the QueryString parameter.
    • urlRewriteFormat of the BlogPost will be broken.

    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.
Register for webinar
4 posts, 0 answered