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

RSS Control

12 posts, 0 answered
  1. Muhammad Saqib
    Muhammad Saqib avatar
    95 posts
    Registered:
    09 Sep 2009
    10 Jun 2010
    Link to this post
    I have created a RSS Feed. ( myweb/News.rss.ashx)
    I want to modify its functionality a bit..
    actually i have added a metafield named "customurl" in News . My intentions was when any one gives the customurl the news link will go to that page instead sitefinity itself creates news page.
    I want the same thing in RSS displaying news. when there is customurl exists for particular news item the click directly goes to that link otherwise default news detail page shows..

    So please help me how can i edit the RSS control...
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Jun 2010
    Link to this post
    Hi Muhammad Saqib,

    You have to create a custom RssChanelProvider and override SetTitle method where you have access to the content item.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
     
    /// <summary>
    /// Summary description for NewsRssChanelProviderCustom
    /// </summary>
    public class NewsRssChanelProviderCustom : Telerik.News.Rss.RssChannelProvider
    {
        public NewsRssChanelProviderCustom()
        {
        
        }
     
        protected override void SetTitle(Telerik.Rss.RssItem item, Telerik.Cms.Engine.IContent content)
        {
            
            string customUrl = (string)content.GetMetaData("someKey");
            if (!String.IsNullOrEmpty(customUrl))
                item.Title = "someValue";
           base.SetTitle(item, content);
        }
    }

    You might find the following discussion useful - How I can hide fields in RSS feed?

    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. Muhammad Saqib
    Muhammad Saqib avatar
    95 posts
    Registered:
    09 Sep 2009
    10 Jun 2010
    Link to this post
    and how i should set this custom rss provider as default news rss provider?
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    10 Jun 2010
    Link to this post
    Hello Muhammad Saqib,

    Yes, you can add it to the channel providers from web.config:
    <rss defaultProvider="Sitefinity">
        <feeds>
        </feeds>
        <channelProviders>
            <clear />
            <add name="My News Rss Provider" type="NewsRssChanelProviderCustom, App_Code" settingsControl="Telerik.News.WebControls.Rss.RssSettingsControl, Telerik.News" viewSettingsControl="Telerik.News.WebControls.Rss.RssViewControl, Telerik.News" description="Provides RSS news"></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>
        <providers>
            <clear />
            <add name="Sitefinity" type="Telerik.Rss.Data.DefaultServiceProvider, Telerik.Rss.Data" connectionStringName="DefaultConnection" />
        </providers>
    </rss>


    Greetings,
    Radoslav Georgiev
    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. Muhammad Saqib
    Muhammad Saqib avatar
    95 posts
    Registered:
    09 Sep 2009
    10 Jun 2010
    Link to this post
    well.. i've already done this.. but its not executing "SetTitle" method inside my custom rss provider.
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    10 Jun 2010
    Link to this post
    Hi Muhammad Saqib,

    Did you remove the already added built in custom provider from your channel and add the new one to your RSS channel?

    Greetings,
    Radoslav Georgiev
    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.
  7. Muhammad Saqib
    Muhammad Saqib avatar
    95 posts
    Registered:
    09 Sep 2009
    10 Jun 2010
    Link to this post
    This is my web.config rss tag

    <rss defaultProvider="Sitefinity">
                <feeds>
                </feeds>
                <channelProviders>
                    <clear/>
            <add name="Custom News Rss Provider" type="CustomNewsRssChannelProvider, App_Code" settingsControl="Telerik.News.WebControls.Rss.RssSettingsControl, Telerik.News" viewSettingsControl="Telerik.News.WebControls.Rss.RssViewControl, Telerik.News" description="Custom Provides RSS for News"/>
            <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>
                    <clear/>
                    <add name="Sitefinity" type="Telerik.Rss.Data.DefaultServiceProvider, Telerik.Rss.Data" connectionStringName="DefaultConnection"/>
                </providers>
            </rss>

    is it correct?
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    10 Jun 2010
    Link to this post
    Hi Muhammad Saqib,

    This is correct but probably you did not understand my question completely. When you go to the back-end did you create a channel with your new provider as in attached image?

    All the best,
    Radoslav Georgiev
    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.
  9. Muhammad Saqib
    Muhammad Saqib avatar
    95 posts
    Registered:
    09 Sep 2009
    10 Jun 2010
    Link to this post
    Oops ..

    yup. it worked Now
    Thanks
  10. bemara57
    bemara57 avatar
    135 posts
    Registered:
    27 Mar 2008
    27 Jul 2010
    Link to this post
    Thanks this helped a lot. I was actually hoping to find the original News RSS entry in the web.config and update the type to my custom class. This way, all sites would automatically start using the custom one without manually changing it in the admin.

    If this is not possible, is there a way to at least remove the original News RSS so it does not show up in the list for the admin?
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    27 Jul 2010
    Link to this post
    Hi bemara57,

    The default Rss is added by NewsModule. NewsModule implements IRssProviderModule interface and Telerik.Rss.WebControls.ControlPanel creates settings for all modules that implements this interface. There is a way that you can remove the default provider from the list without overriding the module. You should edit

    Sitefinity\Admin\ControlTemplates\RssFeeds\ChannelsProvidersLayout.ascx

    <%@ Control Language="C#" %>
     
     
    <script type="text/C#" runat="server">
     
        public void Page_Load(object sender, EventArgs e)
        {
            this.availableSources.ItemDataBound += new RepeaterItemEventHandler(availableSources_ItemDataBound);
        }
     
        void availableSources_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                var linkbutton = e.Item.FindControl("addItem") as LinkButton;
                if (linkbutton != null && linkbutton.Text == "News")
                {
                    linkbutton.Visible = false;
                }
            }
        }
         
         
    </script>
     
    <h3><asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:ChannelsSettings %>"></asp:Literal></h3>
    <asp:PlaceHolder id="providersHolder" runat="server"></asp:PlaceHolder>
    <div class="set">
    <div class="setIn"
    test
     
     
     
    <h4><asp:Literal ID="Literal2" runat="server" Text="<%$ Resources:SelectChannels %>"></asp:Literal></h4>
        <asp:Repeater ID="availableSources" runat="Server">
            <HeaderTemplate>
                <ul class="serviceItemsList">
            </HeaderTemplate>
            <ItemTemplate>
                <li>
                    <asp:LinkButton ID="addItem" runat="server"></asp:LinkButton>
                </li>
            </ItemTemplate>
            <FooterTemplate>
                </ul>
            </FooterTemplate>
        </asp:Repeater>
    </div>
    </div>
    <div class="bottom"><div><!-- --></div></div>


    All the best,
    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
  12. bemara57
    bemara57 avatar
    135 posts
    Registered:
    27 Mar 2008
    27 Jul 2010
    Link to this post
    Thanks Ivan. Because I was adding a custom News Rss Provider, the link name was the same as the original, so it was hiding my custom link as well. So I ended up with this:

    void availableSources_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if(e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            var providerInfo = e.Item.DataItem as Telerik.Rss.RssProviderInfo;
            if(providerInfo != null && providerInfo.Name == "News Rss Provider")
            {
                e.Item.Visible = false;
            }
        }
    }

    Thanks again!
Register for webinar
12 posts, 0 answered