Integrating home grown and feed content with the #drupal aggregator module
On a project that I'm working on, a situation has arose where the client wants to display content that is both generated directly on their site and sourced from external sites (i.e. feeds). To the end user this should be a fairly seamless experience and there are a couple of solutions that should satisfy this requirement.
Concepts to keep in mind.
- Integration of home grown content and content from external sources.
- Provide as seamless a user experience as possible.
- Some sourced content (via feeds) may only contain titles and / or teasers.
Part I will discuss using the Aggregator module. Part II will focus on using the up-and-coming Feeds module.
Update 12/23/2010: When I get a bit more time I'll continue with Part II. Also note the images did no import properly. When I have the time I'll download and repost those pictures.
Aggregator
(core module) (linkage)
Drupal core provides the Aggregator module for optional use. This module basically accepts feed streams and displays the individual pieces of content. Each feed can be categorized if desired.
Thinking back to our requirements above, how do we provide a seamless integrated experience with home grown and feed content? The trick to this is creating a feed of home grown content and then using the Aggregator module to pull it all together.
If you are familiar with the Views (contrib) then you will find it fairly simple to create a feed of the home grown content. I won't get into the specifics of the Views modules, however I'll point out a few details on how to create a feed.
Creating the Feed
- A view feed is a type of display just like a page or block display. Simply select feed from the drop-down and then click on 'add display'.
- You'll notice that the 'Style' setting is set to RSS Feed. If you have various style plug-ins available, go ahead and select one. If not, simply select the 'Row style' of 'Node'.
- Scroll a bit further down and you'll find the 'Path' setting. This is simply the relative URL to get to the feed. Based on the setting in the image below, the feed would be found at mysite.com/feed. You could give the 'Path' setting a value of 'news/rss.xml' to make the feed available at mysite.com/news/rss.xml.
Setting up Aggregator
- After enabling the Aggregator module head on over to Administer -> Content Management -> Feed Aggregator and select the settings tab (admin/content/aggregator/settings). On this tab take notice of the allowed HTML tags. If any of the external feeds contain tags not in this list then they will be stripped out.Determine how many to display and how long until they expire.
- Now that are basic aggregator settings are configured, select the 'Add Feed' tab and let's start adding feeds. Simply add a title for the feed, the URL of the feed, and how often to pull updates. Make sure you have cron correctly configured.We will want to add the home grown feed (mysite.com/feed) that we created above and any external feeds that we're interested in.
Using the Aggregated Feed
Now that we've added all of our feeds and cron has successfully run, we can head on over to mysite.com/aggregator to view the content. I believe there is also a syndicate block provided.
That's it!
The solution isn't perfect but it does the job. I've listed some pros / cons of this solution below.
Pros
- Fewer nodes are created which should help performance in the long run.
- Simpler to setup, at least compared to future examples.
- Clicking on a title takes the user to the source of the content. There isn't duplicate content.
Cons
- External content are not searchable within the main site.
- External content expires. (this may or may not be a con)
- External content cannot be used elsewhere (i.e. other views) on the site.
- Aggregator page displays full body text and not teasers.