More in this section

Forums / Developing with Sitefinity / Accessing page name or keywords in filter expressions

Accessing page name or keywords in filter expressions

2 posts, 0 answered
  1. derek
    derek avatar
    37 posts
    15 Jun 2007
    04 Feb 2009
    Link to this post

    I'm trying to setup a template in sitefinity that contains a filtered blog user control.

    I've created a blog for all of our alumni to post class notes. Each post is tagged with a class year and each page for the years has a display of the blog but filtered on the class year. It works great!

    I've now realized that I should have setup a template to do this, but noticed that I cannot edit the blog user control from the page when it's from the template.

    This means that I have to dynamically setup the filtering in the template.

    Is there a way for me to access the name of the page, or meta keywords from the filter expressions?

    What I am currently doing is:

    Tag.Name = "1989" but what I'll need to do is something like Tag.Name = page.Name

    Is this possible? I tried Tag.Name = page.Details.Name to no avail.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    05 Feb 2009
    Link to this post
    Hi derek,

    Thank you for using our services.

    The solution is overriding BlogPosts control and creating a custom filter. Then add the control in your template. If the page name equals to the tag name of the post, the control will show that post.

    Here is the code with some comments.

    using System; 
    using System.Collections.Generic; 
    using System.Web; 
    using Telerik.Blogs.WebControls; 
    using Telerik.Cms; 
    using Telerik.Cms.Web; 
    using Telerik.Cms.Engine; 
    using Telerik.Cms.Engine.ContentViewFiltering; 
    /// <summary> 
    /// Summary description for FilterExpressionOverride 
    /// </summary> 
    namespace Telerik.Samples 
        public class EnhanceFilterExpressionOverride : BlogPosts 
            protected override void CreateContentList() 
                // get the current page 
                CmsManager manager = new CmsManager(); 
                CmsSiteMapNode newNode = (CmsSiteMapNode)SiteMap.Provider.CurrentNode; 
            private void EnhanceFilterExpression(string tagName) 
                // make sure tag exists 
                if (base.Manager.GetTag(tagName) != null
                    // new instance of filter builder 
                    ContentFilterBuilder filterBuilder = new ContentFilterBuilder(this); 
                    filterBuilder.AddFilter(new ContentFilterStatement("Tag.Name", tagName, ContentFilter.Condition.Equal, ContentFilter.JoinType.And)); 
                    string test = base.FilterExpression; 

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
2 posts, 0 answered