Sometimes it is difficult to write complex xPath and sitecore Queries, to make RSS Feed work like our requirements. So, it is better to Override the Sitecore class called Sitecore.Syndication.PublicFeed.
Example
public class CustomFeed : Sitecore.Syndication.PublicFeed
{
public List<Item> EmbargoPressReleases = new List<Item>();
public override IEnumerable<Sitecore.Data.Items.Item> GetSourceItems()
{
var Items = base.GetSourceItems();
foreach(Item i in Items)
{
if(i.TemplateID == Consts.Template.PressRelease)
{
if(Sitecore.DateUtil.IsoDateToDateTime(i.Fields[Consts.FieldName.PublishDate].ToString()) <= DateTime.Now)
{
EmbargoPressReleases.Add(i);
}
}
}
return EmbargoPressReleases;
}
}
No comments:
Post a Comment