mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Adding tags to RSS feeds
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Feeds;
|
||||
using Orchard.Core.Feeds.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Tags.Models;
|
||||
|
||||
namespace Orchard.Tags.Feeds {
|
||||
[OrchardFeature("Orchard.Tags.Feeds")]
|
||||
public class TagsFeedItemBuilder : IFeedItemBuilder {
|
||||
public void Populate(FeedContext context) {
|
||||
foreach (var feedItem in context.Response.Items.OfType<FeedItem<ContentItem>>()) {
|
||||
// add to known formats
|
||||
if (context.Format == "rss") {
|
||||
|
||||
// adding tags to the rss item
|
||||
var tagsPart = feedItem.Item.As<TagsPart>();
|
||||
if (tagsPart != null) {
|
||||
tagsPart.CurrentTags.ToList().ForEach(x =>
|
||||
feedItem.Element.Add(new XElement("category", x)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,3 +10,8 @@ Features:
|
||||
Description: The tags module is providing basic tagging for arbitrary content types.
|
||||
Dependencies: Settings, Orchard.jQuery
|
||||
Category: Navigation
|
||||
Orchard.Tags.Feeds:
|
||||
Name: Tags Feeds
|
||||
Description: Adds tags to the RSS feeds.
|
||||
Dependencies: Orchard.Tags, Feeds
|
||||
Category: Syndication
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Feeds\TagsFeedItemBuilder.cs" />
|
||||
<Compile Include="Migrations.cs" />
|
||||
<Compile Include="Models\ContentTagRecord.cs" />
|
||||
<Compile Include="Models\TagsPartRecord.cs" />
|
||||
|
||||
Reference in New Issue
Block a user