Turn Affiliate RSS Feeds Into a Website Using Drupal

Introduction

This article provides a tutorial on how to turn affiliate RSS feeds into a website with little or no PHP programming experience using Drupal. With Drupal, you can specify the update interval for each feed, group the feeds and use a view to manipulate the feeds out of the box. Check out the demo here.

Table 1

home_250x250.gifsample2_books_250x200.gif



books_dropdown_250x135.gifsoftware_250x139.gif
     

Getting Started

I assume that Drupal is installed on your hosting account. The theme that I'm using is Marinelli; you can use any other theme. Make sure you have the Views and Chaos tools module installed/enabled and the Aggregator module enabled. Go to Modules, enable Aggregator and hit the save configuration button to enable the Aggregator module. Here are the steps.

1. RSS affiliate feed

Subscribe to RSS feed from Amazon, eBay, link share, etc…

2. Setup Feed Aggregator

In Drupal, go to Configuration, Feed aggregator, click on Setting and include <div> and <img> tag into Allowed HTML tags list. This will allow the image to display in the content feed. After that, click on List and then Add Feed. Fill up the title, RSS Feed URL, Update Interval and save. Repeat the same step for all the feeds and group them by category if necessary.

3. Create View

Go to Structure, View, Add New View. I noticed that the Drupal search module does not work well with view in Block and Page. But there is a Search by Page plug-in we can use to index the page. After providing all the information, click on continue, as in Figure 1.


Figure 1

create_view.gif

On the Fields section, click on add and select "Aggregator: Title" and "Aggregator: Body", click Apply and uncheck the Create a label and hit the Apply button. Then click on the dropdrown icon next to add, select rearrange, delete the field that you don't need and arrange the field accordingly. On the Filter Criteria section, click on add and choose "Aggregator feed: Feed ID ". Then hit Apply, select "Operator is equal to" and in the value box insert any of the Feed IDs created in step 2. You can add a sort criteria to sort the result by Feed ID, Aggregator title, Timestamp, Random, and etc…

Figure 2

view_setting1.png

Hit on the save button and navigate to the page to review the result. You should see something similar to figure 3.

Figure 3

view_result.gif
 
Now, let's decorate it a little bit. Go back to the View, expand the advanced panel, and click on theme information under other. Notice that the selected template is "views-view-fields.tpl.php" instead of "views-view-fields—view-electronic—page.tpl.php". Usually I will modify the later template to customize a single view.

Figure 4

view_row_stylegif.gif

Since we will reuse the same template again, I will go ahead and replace the "views-view-fields.tpl.php" template with the code in listing 1. The title and description field in the code below is corresponding to the fields we selected earlier, refer to figure 2. For simplification sake, I wrap the title and body in the div tag. Depending on your requirements, you can exercise your creativity here.

Listing 1

 <div class="custom_view_title">
<?php print $fields["title"]->content; ?>
</div>
<div class="custom_view_content">
<?php print $fields["description"]->content; ?>
</div>

Next, let's create the style for the "custom_view_title" and "custom_view_content" class. In this tutorial, we will put all the styles in a separate file. If your theme is not inside the themes folder, look under Sites>all>themes. Create a new file with the name custom.css with the styles in listing 2 and upload it to the theme, css folder.

Listing 2

 .custom_view_title {
background-color:#000;
opacity:.7;
filter: alpha(opacity = 70);
border-left:1px solid #828282;
border-right:1px solid #828282;
border-bottom:1px solid #828282;
padding: 2px;
}
.custom_view_content {
min-height:180px;
border-left:1px solid #828282;
border-right:1px solid #828282;
border-bottom:1px solid #828282;
padding:2px;
}
.custom_view_content img {
float:left;
padding: 2px;
}

Open your theme .info file. If your theme is bartik, then the file name should be bartik.info. Add stylesheets[all][] = css/custom.css on top of stylesheets[all][] = css/layout.css line. Go to Configuration, Performance, Clear all caches and navigate to the page to review the result again.

Figure 5

view_result_after_style.gif

4. Create More Views

Go to Structure, View and find the view created earlier, under operations select clone. Give the view a new name, modify the title and provide a different Feed ID under filter criteria. On the page settings, modify the path and hit the save button. Repeat this step if necessary.

Figure 6

create_more_view.gif
 
We also can filter by group and then Feed ID; take a look at figure 7.

Figure 7

view_group_by.gif

5. Create Menu

The next step is to decorate the menu. If the menu from the theme is not fancy enough, you always can try another plug-in such as superfish. I'm not going to cover the menu here and you can find many good resources on Google.

Conclusion

I hope someone will find this article useful. Please drop me a line if you have any questions.

Demo