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

Forums / Developing with Sitefinity / Custom RSS provider for Blog Module for not displaying the “author” field

Custom RSS provider for Blog Module for not displaying the “author” field

10 posts, 0 answered
  1. kiran
    kiran avatar
    43 posts
    Registered:
    17 Nov 2010
    10 Feb 2011
    Link to this post

    Hello,

    We currently use Sitefinity 3.7 SP3 version for our web sites. We use the default RSS feed services in Sitefinity to create a feed for our Blog in our website. We have a feed such as “~/sitename.rss.ashx”.

    After looking at the xml that is generated from this feed we found that the <author></author> field is generated by default by Sitefinity RSS provider for the Blog module. We don’t want to display this <author> in the generated xml file.  Is this possible to accomplish this? I have looked at some example for hiding fields for the News module, but I could not find anything specific for implementing this for a blog module. Could you please suggest me some posts where I can find some instructions and any sample code pertaining to hide the “author” field for the Blog module.

    Could you please provide us with some sample code and instruction on how to accomplish to this?

    Thank you for all your time.

    Regards,
    Kiran.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Feb 2011
    Link to this post
    Hi kiran,

    The easiest option here is setting an empty string for the author in a custom rss provider. Here is  a sample code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Blogs.Rss;
    using Telerik.Cms.Engine;
     
    /// <summary>
    /// Summary description for BlogsRssChanelCustom
    /// </summary>
    public class BlogsRssChanelCustom : Telerik.Blogs.Rss.RssChannelProvider
    {
        public BlogsRssChanelCustom()
        {
     
        }
     
     
     
        public override IList<Telerik.Rss.RssItem> GetRssItems(System.Collections.Specialized.NameValueCollection query)
        {
            //return base.GetRssItems(query);
            IList<Telerik.Rss.RssItem> items = base.GetRssItems(query);
            foreach (Telerik.Rss.RssItem i in items)
            {
     
                i.Author = "";
     
     
            }
            return items;
        }
     
     
    }


    Another option is creating  a custom class that inherits from RssHttpHandler and there you have to override GetContentData where you can remove the entire <author> tag from the feed.

    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. kiran
    kiran avatar
    43 posts
    Registered:
    17 Nov 2010
    10 Feb 2011
    Link to this post
    Hello Ivan, Thank you for your prompt. After creating the custom provider, do I need to add this to the web.config file. If so could you please le me know about the tag that needs to be modified. Thank again for your prompt reply. Regards, Kiran.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Feb 2011
    Link to this post
    Hi kiran,

    Here is how the provider should be registered

    <rss defaultProvider="Sitefinity">
                <feeds>
                </feeds>
                <channelProviders>
                    <clear />
            <add name="Custom Rss Provider" type="ExtendedRssChanelProvider, App_Code" settingsControl="ExtendedRssSettignsControl, App_Code" viewSettingsControl="ExtendedRssViewControl, App_Code" description="extended RSS provider for blogs"></add>

    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
  5. kiran
    kiran avatar
    43 posts
    Registered:
    17 Nov 2010
    10 Feb 2011
    Link to this post
    Hello Ivan,

    Thank you for your reply. But for some reason, I am getting an error after I create the class and refer it from the web.config file.

    I have added a class named "BlogsRssChanelCustom.cs"  in the App_Code folder in the project and the code is below:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Blogs.Rss;
    using Telerik.Cms.Engine;
      
      
    /// <summary>
    /// Summary description for BlogsRssChanelCustom
    /// </summary>
    public class BlogsRssChanelCustom : Telerik.Blogs.Rss.RssChannelProvider
      
    {
        public BlogsRssChanelCustom()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public override IList<Telerik.Rss.RssItem> GetRssItems(System.Collections.Specialized.NameValueCollection query)
        {
            //return base.GetRssItems(query);
            IList<Telerik.Rss.RssItem> items = base.GetRssItems(query);
            foreach (Telerik.Rss.RssItem i in items)
            {
      
                i.Author = "";
                
      
            }
            return items;
        }
       
      
      
    }

    As suggested in your previous response, I have added this line to the web.config file as:


    <rss defaultProvider="Sitefinity">
                <feeds>
                </feeds>
                <channelProviders>
                    <clear/>
            <add name="Custom Rss Blog Provider" type="BlogsRssChanelCustom, App_Code" settingsControl="ExtendedRssSettingsControl, App_Code" viewSettingsControl="ExtendedRssViewControl, App_Code" description="extended RSS provider for blogs"></add>
                    <add name="Page Rss Provider" type="Telerik.Cms.Web.RssChannelProvider, Telerik.Cms" settingsControl="Telerik.Cms.Web.UI.RssSettingsControl, Telerik.Cms" viewSettingsControl="Telerik.Cms.Web.UI.RssViewSettingsControl, Telerik.Cms" description="Provides RSS for CMS pages"/>
                </channelProviders>


    After this I went to the Sitefinity Adminsitration side to create the RSS feed using this new custom RSS provider. But for some reason the name still show as "Blog" even tough I have given it a name "Custom Rss Blog Provider" as shown in the above web.config file.

    And for some reason I get this error to when I click the "Blog" feed. I am attaching both the issues. Please could you let me know if I am doing something wrong.

    Thank you,
    Kiran.




  6. kiran
    kiran avatar
    43 posts
    Registered:
    17 Nov 2010
    10 Feb 2011
    Link to this post
    Hello Ivan,

    Never mind. We got it to work. Thank you for your really quick replies. Thank you!!!

    Regards,
    Kiran.
  7. Daryl
    Daryl avatar
    2 posts
    Registered:
    28 Oct 2010
    25 May 2011
    Link to this post
    Hi guys - I am trying to do this very thing and I am a bit confused by the settingsControl and the viewSettings control attributes in the web.config.  What are those types? Do I use the RssViewSettingsControl in the default channelprovider?

    **UPDATE - I figured this out - I wanted the blog settings so I used this:

    settingsControl="Telerik.Blogs.WebControls.Rss.RssSettingsControl, Telerik.Blogs" viewSettingsControl="Telerik.Blogs.WebControls.Rss.RssViewControl, Telerik.Blogs"

    Thanks!
  8. kiran
    kiran avatar
    43 posts
    Registered:
    17 Nov 2010
    25 May 2011
    Link to this post

    Hello Daryl,

     

    Below are the steps we followed to create a custom RSS Channel provider.

    1. Create a new class in the App_Code folder that inherits from the Telerik.Blogs.Rss.RssChannelProvider class.
    2. In this class override the GetRssItems method with the properties or methods that you would like to change. For example the code below provides a “null” value to each of the blog items. (as mentioned by Ivan above.)

    public class BlogsRssChanelCustom : Telerik.Blogs.Rss.RssChannelProvider
    {
    public BlogsRssChanelCustom()
    {
    //
    // TODO: Add constructor logic here
    //
    }
    public override IList<Telerik.Rss.RssItem> GetRssItems(System.Collections.Specialized.NameValueCollection query)
    {
    //return base.GetRssItems(query);
    IList<Telerik.Rss.RssItem> items = base.GetRssItems(query);
    foreach (Telerik.Rss.RssItem i in items)
    {
    i.Author = "";
    }
    return items;
    }
    }

    1. After adding the class you need to refer this custom provider in the web.config file. Add the reference in the web.config with following code. You just need to add the new custom provider on top of the Page Rss Provider”.
    <rss defaultProvider="Sitefinity"
                      <feeds
                      </feeds
                      <channelProviders
                            <clear/> 
            <add name="Custom Rss Blog Provider" type="BlogsRssChanelCustom, App_Code" settingsControl="Telerik.Blogs.WebControls.Rss.RssSettingsControl, Telerik.Blogs" viewSettingsControl="Telerik.Blogs.WebControls.Rss.RssViewControl, Telerik.Blogs" description="Custom Provides RSS for Blogs"/> 
    <add name="Page Rss Provider" type="Telerik.Cms.Web.RssChannelProvider, Telerik.Cms" settingsControl="Telerik.Cms.Web.UI.RssSettingsControl, Telerik.Cms" viewSettingsControl="Telerik.Cms.Web.UI.RssViewSettingsControl, Telerik.Cms" description="Provides RSS for CMS pages"/> 
                      </channelProviders
                      <providers>

    4. After adding these two bits of code you should be able to find the new “Blog” module in the Administration side. Create the RSS feeds using this new custom module.

  9. Daryl
    Daryl avatar
    2 posts
    Registered:
    28 Oct 2010
    26 May 2011
    Link to this post
    Kiran!

    Thanks for your help.  That is what I essentially did and it works great when I am running it on my local machine inside Visual Studio.

    When I deploy it to the server IIS 7 2008 Server R2 - I receive a 404 for all RSS Feeds even the ones that don't use the new Custom RSS provider.

    Any ideas?

    Daryl
  10. kiran
    kiran avatar
    43 posts
    Registered:
    17 Nov 2010
    26 May 2011
    Link to this post
    Hello Daryl,

    As you are saying you are getting an 404 error for all the feeds, I can think of only one thing. May be the Feed URL that you are creating for the RSS feed is not in the correct format. It should be something like: ~/blogs.rss

    I am attaching a graphic which shows the wrong way of doing it, then I get the 404 resource not found error. I did not put the "~" , to see the error. And when I do that I get the 404 error. So do check the Feed URL.

Register for webinar
10 posts, 0 answered