Displaying Feeds

Displaying Feeds

Displaying RSS Feeds

  • Feed entry items appear as entries in RSS feeds
    • Configure the standard values on the data template
    • Use the Feed device
    • Add a control that inherits from Sitecore.Web.UI.WebControls.FeedRenderer
    • Use Presentation >> Feeds >> Design in the Content Editor to specify the TitleField, BodyField and DateField parameters of the control
  • Feed definition items define which items to include in a feed
    • Must use the System/Feeds/RSS Feed data template
    • Set layout details for any device to activate the System/Feed Delivery Layout

Disabling RSS Feeds

  • Locate the <httpHandlers> section of the web.config file
  • Remove <add verb="*" path="sitecore_feed.ashx" type="Sitecore.Shell.Feeds.FeedRequestHandler, Sitecore.Kernel"/>
  • This disables the Sitecore client feeds, public feeds are still available to Web site visitors
  • Use http://feedvalidator.org/ to validate feeds


C# Web Control Code

Sitecore.Data.Database db = Sitecore.Context.Database;

Sitecore.Data.Items.Item item = db.GetItem("itempath");

if (item != null)

{

      using (new Sitecore.SecurityModel.SecurityDisabler())

      {

             string title = item.SelectSingleNode("title").InnerText;

             title = Regex.Replace(title, @"[\[\]?:\/*""<>|]", "");

             string description = item.SelectSingleNode("description").InnerText;

             Sitecore.Data.Items.Item RssItem =

item.Add(title, Sitecore.Context.Database.GetTemplate("{11111111-1111-1111-1111-111111111111}"));

             if (RssItem != null)

             {

                   using (new EditContext(NewRssItem))

                   {

                          NewRssItem.Fields["Title"].Value = title;

                          NewRssItem.Fields["Description"].Value = description;

                          NewRssItem.Fields["__Display Name"].Value = title;

                   }

 

             }

      }

}

Sources