This tutorial will be split into three parts - part 1 (this part) will explain how to set up the aggregation and import feeds, part 2 (to be published next post) will explain setting up cron to handle auto updating the feeds and will also cover using views to create some different site sections, and part 3 (to be published the post after that) will explain how to theme everything. In the tutorial I will be building a Drupal based sports news aggregation site, but you can obviously tailor this to whatever type of news items you'd like.
The goals:
You can check out the finished aggregation site (part 1) here.
The set up:
For this tutorial I'll be using the following:
A quick word on SimpleFeed vs other aggregation modules:
There are a number of other aggregation modules available for Drupal. From my own experience the two best are SimpleFeed and FeedAPI. FeedAPI has excellent functionality and can do some very cool stuff (for example, check out this video on drupaltherapy.com which shows how to use FeedAPI and feed element mapping). However, in this case I've chosen to use SimpleFeed because I don't require any of this extra functionality and SimpleFeed is, well, the simplest to use.
Step 1: Set up the site and modules
Set up your Drupal site and then download and install the SimpleFeed module and the Views module. Select the following options for each module:
Step 2: Install the missing simplepie.inc file
In order for SimpleFeed to work correctly it requires that we place the simplepie.inc file from the SimplePie library into our SimpleFeed module directory. If you currently go to your status report (admin/logs/status) you'll see the following error alerting you to this fact:
So, to sort this out do the following:
Now when you check your status report page you should not see any errors.
Step 3: Set up a vocabulary
In order to theme our news items more effectively, and to help us with filtering and sorting news items, we're going to assign taxonomy terms to them. SimpleFeed includes auto-assign functionality for taxonomy terms which will be very helpful here.
First, go to the 'Add vocabulary' subsection of the 'Categories' admin section (admin/content/taxonomy/add/vocabulary). Then create a vocabulary with the following settings:
Step 4: Configure your SimpleFeed settings
There are a few places where we can configure settings for SimpleFeed:
SimpleFeed settings page
The SimpleFeed settings (admin/settings/simplefeed) are fairly self explanatory. In this
case we will use the following settings:
'Discard feed items older than:'
we always want our feed items to be available to users so we set this to 'Never'.
'Check feeds every:'
1 hour is good here as sports news is quite frequent, so we want to check for updates
often.
'Default input format:'
we'll start be leaving this as the default 'Filtered HTML' option which will filter out
any HTML tags that are not specified in the input format settings (admin/settings/filters).
However, with RSS feeds you can find that unclosed tags in a feed item will have an
adverse effect on the rest of your page so you may need to remove further tags options
after some testing.
'Vocabulary'
set this to 'Source' which was the vocabulary we set up in the previous step. This will
allow feed items to automatically inherit their parent's taxonomy terms.
'Automatically add categories set by external feeds to the vocabulary above'
we will leave this unchecked as we want to tightly control the taxonomy.
'Cron throttle'
the default 50 will be plenty for now!
Access control 'simplefeed module' settings
For this tutorial we're not going to change anything here, but you may want to depending upon the site usage.
'Feed' content type settings page
By default both the 'Feed' content type and the 'Feed Item' content type have their 'Default comment setting:' option set to 'Read/Write'. In this case we don't want users commenting on either so we'll change them to 'Disabled'.
To do so, first go to the 'Feed' content type settings page (admin/content/types/feed) and
scroll down to the 'Workflow' section. Then just change the 'Default comment setting:'
option to 'Disabled'.
'Feed Item' content type settings page
Do the same as for the 'Feed' content type and set the 'Default comment setting:' option to
'Disabled'.
Step 5: Find some RSS feeds
As this is going to be a sports news aggregation site I've gathered together the following RSS feed URLs and chosen a taxonomy term for each:
Just remember to check the terms of use sections on each of the websites regarding the republishing of feed content.
Step 6: Add your RSS feeds
Now everything is set up, let's add some feeds!
Go to 'Create content > Feed'. We'll start by adding the BBC sport front page feed with the following settings (the feed URL and taxonomy term are taken from Step 5 above):
We've already taken care of all of the other settings (like input format, comment settings), so hit 'Submit'. The feed will be created and you should get the following confirmation screen:
Now we need to actually import the feed items.
We could wait for our cron job (which we'll set up in part 2 of the tutorial) to fire and trigger the auto update of the feed for us, but for now we'll do it manually.
So, click on the 'Refresh this feed' link and SimpleFeed will look for, and import, the new feed items. SimpleFeed imports each feed item as a node. After a second or two it should have found the new items, created the nodes, and output the following success message:
One quick thing to note here is the first line 'The directory files/cache_simplefeed has been created'. If file permissions for this folder are not set correctly on your server it can cause cron errors, but we'll deal with this later on if it's a problem.
Finished! (Part 1)
If you now check the front page of your site you should see all of the feed items from the BBC front page RSS feed. Go ahead and add the other feeds the same way as the BCC feed (using the feed URLs and taxonomy terms from Step 5 above). The site won't do a lot yet, though, so we'll sort that out in part 2.
Coming soon...
In part 2 we'll set up cron to handle auto updating the feeds and also use views to create some different sports sections (football and baseball) and RSS feeds.
In part 3 we'll get to theming everything.
Simple bit of Drupal module code from yesterday: permissions are provided for each node type which can have attachments, providing a more granular permission set based on node type. Then, we alter any node add/edit forms and remove (using PHP's unset) the attachments part of the form based on these new permissions.
Check the code out after the break, hope its of some use somewhere. Does anyone have any thoughts on unsetting form elements like this? Is it a wise thing to do, or is there a better way?
A drupal webmaster/ person to do basic site upgrades and bug fixing...
...is needed for vibrant music video startup RadarMusicVideos.com. There will be access to the lead developer and potentially to other music based projects. Part time, £50 per week. This would suit a current student looking for opportunities to build their CV and develop professional contacts with other music-based platforms.
Please send your CV to caroline@radarmusicvideos.com
United Kingdom
Recent comments
9 hours 42 min ago
18 hours 54 min ago
2 days 2 hours ago
2 days 2 hours ago
3 days 8 hours ago
4 days 3 hours ago
4 days 7 hours ago
5 days 5 hours ago
6 days 4 hours ago
6 days 7 hours ago