I’m using full RSS feeds on all my Drupal installation, because I really think it’s the right thing to do. Although it cuts down the page views which leads to less ad clicks, it’s worth the feeling of giving the users a better browsing experience for the information that I provide. But, I was looking for a way to increase pageviews for those who are reading my Drupal sites with keeping them in Full feed mode, and that’s when I thought I should offer a nice added feature of showing the users links to related content.

While there are a few modules that do Related Links for the websites, there aren’t any that allow this for the RSS feed. So, I combined two modules that I was already using – Total Feeds and Similar Entries.

I quickly added a small export to an internal function in Similar Entries by adding the following lines to the module :

function similar_content_feed($node) {
    return _similar_content($node);
}

and then used the declared similar_content_feed in Total Feeds by applying the following change in the _totalfeeds_prepare_item function :

$feedItem->pubDate = $item->created;
$feedItem->lastUpdate = $item->changed;
$feedItem->guid = $feedItem->link;
$feedItem->baseURL = $base_url;
$feedItem->authorName = $item->name;

$mode = variable_get(”totalfeeds_mode”, TOTALFEEDS_TEASER_AND_FULL_TEXT);
$feedItem->description = $item->teaser;

if (module_exist(’similar’)){
    $feedItem->content = $item2->body . ‘The following articles might be of interest to you, too : ‘. similar_content_feed($item2);
}
else {
    $feedItem->content = $item2->body;
}
if ($mode == TOTALFEEDS_TEASER_ONLY) {
    $feedItem->content = $item->teaser;
}
if ($mode == TOTALFEEDS_FULL_TEXT_ONLY) {
    $feedItem->description = $item2->body;
}

Please note that the following was changed :

if (module_exist(’similar’)){
    $feedItem->content = $item2->body . ‘The following articles might be of interest to you, too : ‘. similar_content_feed($item2);
}
else {
    $feedItem->content = $item2->body;
}

And it should work. Only thing to consider is that it’s a CPU expensive function, but since the RSS feed is cachable, and I’m assuming you’re using somesort of Drupal caching, then this shouldn’t bother you too much.

Tagged with:
 

Leave a Reply

Your email address will not be published. Required fields are marked *

Set your Twitter account name in your settings to use the TwitterBar Section.