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

Forums / Developing with Sitefinity / Events RSS Provider

Events RSS Provider

11 posts, 0 answered
  1. Joe
    Joe avatar
    64 posts
    Registered:
    05 Jul 2012
    24 Apr 2008
    Link to this post
    Has any written an Events RSS Provider or gotten the Events RSS Provider to work?  I have tried adding an entry into the web.config.
    <rssProviders> 
      <clear/> 
      <add name="Blogs" type="Telerik.Blogs.RssProvider, Telerik.Blogs" visible="True" applicationName="/Blogs" rssFieldAuthor="Author" rssFieldTitle="Title" rssFieldPubDate="Publication_Date"/> 
      <add name="Events" type="Telerik.Events.Rss.RssChannelProvider, Telerik.Events" visible="True" applicationName="/Events" rssFieldAuthor="Author" rssFieldTitle="Title" rssFieldPubDate="Publication_Date"/> 
    </rssProviders> 

    But no luck.  After looking at the code in Reflector, the RssProviderService Initialize method loads modules that implement IRssProviderModule but there are no classes in the Telerik.Events assembly that implement this Interface.

    Thanks,
    Joseph Guadagno
    http://www.sevdnug.org
  2. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    28 Apr 2008
    Link to this post
    Hello Joseph,

    unfortunately the RssProvider for Events module has not been implemented yet. We are going to try to have it ready for SP 2 release, by the end of May.

    Thanks for pointing out this issue and I apologize for not making it more transparent that rss provider has not been implemented by Events module.

    Sincerely yours,
    Ivan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Joe
    Joe avatar
    64 posts
    Registered:
    05 Jul 2012
    29 Apr 2008
    Link to this post
    Considering that most of the code was done (at least according to Reflector), I would think that Telerik should have implemented the RSS Provider and delayed the "Service Pack" by a day or so. 

    I personally would rather have a full module than one with missing and essential functionality.
  4. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    29 Apr 2008
    Link to this post
    Hi Joseph,

    I understand your point. We didn't think that RSS would be an essential part of the Events module and therefore we've decided to postpone it.

    Once again, thank you for pointing out this feature as an essential one to you. As I have said, we are going to try to ship it with SP 2.

    Best wishes,
    Ivan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Scott
    Scott avatar
    3 posts
    Registered:
    23 Jul 2008
    26 Aug 2008
    Link to this post
    Did the RSS Provider for Events ship with SP2? 

    If not, can you provide some sample code that would provide a head start for implementing this on our own? 

    At this point, I investigating the use of the News Module to publish my Events.  There are some drawbacks to this approach, but at least it has RSS.
  6. Joe
    Joe avatar
    64 posts
    Registered:
    05 Jul 2012
    26 Aug 2008
    Link to this post
    It did not make it into the release (that I know off).  I will see if I can put something together tonight.

    Joseph Guadagno
    Southeast Valley .NET User Group
  7. Scott
    Scott avatar
    3 posts
    Registered:
    23 Jul 2008
    26 Aug 2008
    Link to this post
    Update: I looked more closely at how the RSS is implemented and I see that module itself (in this case, the Events module) needs to implement the RSS interfaces.  As a result, an end user cannot tack on this functionality to the Events module.

  8. Joe
    Joe avatar
    64 posts
    Registered:
    05 Jul 2012
    26 Aug 2008
    Link to this post
    That is true, but you can build a component or library that will read the Events data and generate an rss feed for it until Telerik implements the functionality.
  9. Joe
    Joe avatar
    64 posts
    Registered:
    05 Jul 2012
    27 Aug 2008
    Link to this post
    I have a rough draft workaround that should be able to be used as a RSS feed for Events using the Telerik RSS libraries.

    In order for this to work, you will need to create an external page in Sitefinity for whatever name you choose.  If you are not sure on how to create an external page in Sitefinity check out the section in the manual,  I used EventFeed.aspx.  After that, it is as easy as these few methods. Most of the work is done in the Page_Load event from 20-67, these rest are helper methods to get the URL.

    I hope this helps.
    Joseph Guadagno
    Southeast Valley .NET User Group

    1using System; 
    2using System.Collections; 
    3using System.Web; 
    4using Telerik; 
    5using Telerik.Cms.Engine; 
    6using Telerik.Rss; 
    7using Telerik.Events; 
    8using Telerik.Web; 
    9 
    10/// <summary> 
    11/// Sample RSS Feed Page 
    12/// </summary> 
    13public partial class EventFeed : System.Web.UI.Page 
    14
    15    private EventsManager _manager; 
    16    private string _uriBase; 
    17 
    18    protected void Page_Load(object sender, EventArgs e) 
    19    { 
    20        // Create the channel 
    21        RssChannel channel = new RssChannel(); 
    22        channel.Title = "Southeast Valley .NET User Group Events"
    23        channel.Description = "The events for my site."
    24        channel.Link = new Uri("http://www.sevdnug.org"); 
    25        channel.Copyright = "(c) 2008, Southeast Valley .NET User Group."
    26        channel.Language = "US"
    27        channel.LastBuildDate = DateTime.Now; 
    28        channel.ManagingEditor = "admin@sevdnug.org"
    29        channel.WebMaster = "jguadagno@sevdnug.org"
    30 
    31        // Create the Category 
    32        RssCategory rssCategory = new RssCategory(); 
    33        rssCategory.Name = "Events"
    34        channel.Categories.Add(rssCategory); 
    35 
    36        // create new instance of EventsManager 
    37        _manager = new EventsManager("Events"); 
    38        // get all events 
    39        IList listOfAllEvents = _manager.GetEvents(); 
    40        if (listOfAllEvents.Count > 0) 
    41        { 
    42            foreach (IEvent eventItem in listOfAllEvents) 
    43            { 
    44                RssItem rssItem = new RssItem(); 
    45                rssItem.Title = eventItem.EventTitle; 
    46                IContent content = eventItem.ContentItem; 
    47                rssItem.Description = content.Content == null"": content.Content.ToString(); 
    48                // Get the Item URL 
    49                string itemUrl = getItemUrl(content, "~/Events.aspx"); 
    50                itemUrl = FixUrl(itemUrl); 
    51                itemUrl = GetAbsolutePath(itemUrl); 
    52                rssItem.Link = new Uri(itemUrl); 
    53                rssItem.Author = (string) content.GetMetaData("Author"); 
    54                rssItem.Categories.Add(rssCategory); 
    55                rssItem.Comments = ""// You can do want you want with this. 
    56                rssItem.Guid = new RssGuid(Guid.NewGuid().ToString()); 
    57                rssItem.PubDate = content.DateCreated; 
    58                channel.Items.Add(rssItem); 
    59            } 
    60        }  
    61 
    62        // Create the Telerik RSS Writer 
    63        Telerik.Rss.RssWriter writer = new RssWriter(this.Context.Response.OutputStream); 
    64        writer.Write(channel); 
    65        writer.Close(); 
    66 
    67    } 
    68
    69    #region URL Methods 
    70    /// <summary> 
    71    /// Gets the item URL. 
    72    /// </summary> 
    73    /// <param name="contentItem">The content.</param> 
    74    /// <param name="singleItemUrl">The single item URL.</param> 
    75    /// <returns></returns> 
    76    private string getItemUrl(IContent contentItem, string singleItemUrl) 
    77    { 
    78        string str = string.Empty; 
    79        string str2 = string.Empty; 
    80        string path = singleItemUrl; 
    81 
    82        if (string.IsNullOrEmpty(path) && (CmsContext.CurrentUrl != null)) 
    83        { 
    84            path = CmsContext.CurrentUrl.Path; 
    85        } 
    86        else 
    87        { 
    88            str = "&"
    89            if (string.IsNullOrEmpty(Context.Request.QueryString["ReturnURL"])) 
    90            { 
    91                str2 = "ReturnURL=" + Context.Server.UrlEncode(Context.Request.RawUrl); 
    92            } 
    93            else 
    94            { 
    95                str2 = "ReturnURL=" + Context.Server.UrlEncode(Context.Request.QueryString["ReturnURL"]); 
    96            } 
    97        } 
    98        if (string.IsNullOrEmpty(contentItem.Url)) 
    99        { 
    100            int index = path.IndexOf('?'); 
    101            if (index != -1) 
    102            { 
    103                path = path.Substring(0, index); 
    104            } 
    105            path = string.Concat(new object[] { path, "?""CntProv=", contentItem.ProviderName, "&""CntItem=", contentItem.ID, str, str2 }); 
    106        } 
    107        else 
    108        { 
    109            string str4 = contentItem.Url + _manager.Provider.ContentExtension; 
    110            if (this._manager.Provider.UrlFormatQueryStringIndex != -1) 
    111            { 
    112                str4 = str4 + "?" + ContentUrlRewriterService.FormatURL(contentItem, _manager.Provider, ContentUrlRewriterService.FormatOptions.QueryString); 
    113            } 
    114            else if (str.Length > 0) 
    115            { 
    116                str = "?"
    117            } 
    118            if (!str4.StartsWith("~")) 
    119            { 
    120                int length = path.LastIndexOf('.'); 
    121                if (length != -1) 
    122                { 
    123                    path = path.Substring(0, length); 
    124                } 
    125                else 
    126                { 
    127                    length = path.IndexOf('?'); 
    128                    if (length != -1) 
    129                    { 
    130                        path = path.Substring(0, length); 
    131                    } 
    132                } 
    133                str4 = VirtualPathUtility.RemoveTrailingSlash(path) + str4; 
    134            } 
    135            path = str4 + str + str2; 
    136        } 
    137 
    138        IUrlService languageService = UrlServices.GetLanguageService(); 
    139        if (languageService != null
    140        { 
    141            return languageService.ResolveLanguageUrl(path); 
    142        } 
    143        return path; 
    144 
    145    } 
    146    /// <summary> 
    147    /// Fixes up URLs that include the ~ starting character and expanding 
    148    /// to a full server relative path the URL to fix upF 
    149    /// </summary> 
    150    /// <param name="Url">The URL.</param> 
    151    /// <returns>The fulling qualified URL</returns> 
    152    public static string FixUrl(string Url) 
    153    { 
    154 
    155          if (Url.StartsWith("~") ) 
    156 
    157                return  (HttpContext.Current.Request.ApplicationPath + 
    158                        Url.Substring(1)).Replace("//","/"); 
    159 
    160          return Url; 
    161 
    162    } 
    163 
    164    private string UriBase 
    165    { 
    166        get 
    167        { 
    168            if (string.IsNullOrEmpty(this._uriBase)) 
    169            { 
    170                string absolutePath = HttpContext.Current.Request.Url.AbsolutePath; 
    171                string absoluteUri = HttpContext.Current.Request.Url.AbsoluteUri; 
    172                this._uriBase = absoluteUri.Substring(0, absoluteUri.IndexOf(absolutePath)); 
    173                if (this._uriBase.EndsWith("/")) 
    174                { 
    175                    this._uriBase.Remove(this._uriBase.Length - 1, 1); 
    176                } 
    177            } 
    178            return this._uriBase; 
    179        } 
    180    } 
    181 
    182    private string GetAbsolutePath(string relativePath) 
    183    { 
    184        if (!relativePath.StartsWith("http://")) 
    185        { 
    186            return (this.UriBase + relativePath); 
    187        } 
    188        return relativePath; 
    189    } 
    190    #endregion URL Methods 
    191
    192 




  10. Scott
    Scott avatar
    3 posts
    Registered:
    23 Jul 2008
    27 Aug 2008
    Link to this post
    Joseph,

    Thanks for the effort.  This was a big help.  I modified it just a bit to make sure it doesn't list items that have either expired or ones that have not reached their publication date.  Additionally, I corrected the time to use GMT (so that it is displayed correctly when it later converts to local time).  Just this segment needs to change.  The one last thing I see the the News RSS Provider implents that I didn't bother with is only showing selected categories.  This code follows the implementation used by the New RSS Provider:

          // create new instance of EventsManager  
            _manager = new EventsManager("Events"); 
            // get all events  
            //IList listOfAllEvents = _manager.GetEvents(); 
            List<IMetaSearchInfo> searchInfoList = new List<IMetaSearchInfo>(); 
            searchInfoList.Add(new MetaSearchInfo(MetaValueTypes.DateTime, _manager.PublicationDateField, DateTime.Now, SearchCondition.LessOrEqual)); 
            searchInfoList.Add(new MetaSearchInfo(MetaValueTypes.DateTime, _manager.ExpirationDateField, DateTime.Now, SearchCondition.GreaterThen)); 
            IList listOfAllEvents = _manager.Content.GetContent(0, int.MaxValue, "", ContentStatus.Published, searchInfoList.ToArray()); 
     
            foreach (IContent content in listOfAllEvents) 
            { 
                RssItem rssItem = new RssItem(); 
                rssItem.Title = content.GetMetaData("Title") as string; 
                rssItem.Description = content.Content == null ? "" : content.Content.ToString(); 
                // Get the Item URL  
                string itemUrl = getItemUrl(content, "~/NewsAndEvents/Events.aspx"); 
                itemUrl = FixUrl(itemUrl); 
                itemUrl = GetAbsolutePath(itemUrl); 
                rssItem.Link = new Uri(itemUrl); 
                rssItem.Author = (string)content.GetMetaData("Author"); 
                rssItem.Categories.Add(rssCategory); 
                rssItem.Comments = ""; // You can do want you want with this.  
                rssItem.Guid = new RssGuid(Guid.NewGuid().ToString()); 
                rssItem.PubDate = content.DateCreated.ToUniversalTime(); 
                channel.Items.Add(rssItem); 
            } 

    Best Regards,

    Scott Stout
  11. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    28 Aug 2008
    Link to this post
    Hi Joseph & Scott,

    Joseph, we'd like to thank you for providing the community with this valuable contribution, as well as we'd like to thank Scott for building on top of it.

    We are always very excited and proud when we see community contributions. We have updated your Telerik accounts for this!

    Let us know if there is anything we can do to help you with your future endeavors.

    Regards,
    Ivan
    the Telerik team

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