I'm using FeedAPI Node and the Common Syndication Parser for a site my organization is working on. I'm pulling in feeds from several outside blogs, and creating nodes for each item so that we can pick and choose which ones get showcased on this site -- and also be able to rewrite the teaser, if necessary, to give the proper context.
The goal, though, is to send a reader directly to the original post -- not to the node that's been created on my site. That was easy to do in the custom node.tpl.php file for this content type, by simply changing...
<h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
to this:
<h2><a href="<?php print $node->links['feedapi_original']['href'] ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
In my site's own RSS feed, though, headlines for any of these items that "make the cut" and get published link back to the node on mysite, not -- ie, back to $node_url rather than to $node->links['feedapi_original']['href'].
I floated this question over in the RSS & Aggregation Group a couple days ago, and have done some more digging and experimenting since then. This post at 2Bits seems to come closest to offering a way to alter the RSS structure without hacking core, by invoking hook_nodeapi, but my attempt to modify their "add-an-image" example to instead change the URL:
<?php
function custom_nodeapi(&$node, $op, $teaser, $page) {
switch($op) {
case 'rss item':
$extra = NULL;
if ($node->type == 'affiliated_blog') {
// This is an node created by Feed-API slurping, use a different URL
$link = $node->links['feedapi_original']['href'];
return;
}
}
}
... isn't cutting it.
Is there an easy way to do this? Something obvious that I'm missing? Any help would be much appreciated.
(And sorry for the long-winded post. But if I am on the right track, hopefully the links and code snippets will be helpful to others down the line.)
TKS
Comments
Comment #1
t3knoid commentedYour requirement sounds similar to what I want to do. I have a Digg-like website that uses the Storylink module. What I wanted was to have the RSS feeds point to the original link instead of the nodes in my website. I was able to accomplish thi by doing the following:
In the function node_feed inside node.module, I replaced the following line:
$link = url("node/$node->nid", NULL, NULL, 1);
with the following:
$links = links_load_links_for_node($node->nid, 'vote_storylink', 0, TRUE);
$link = $links[0]['url'];
Comment #2
TKS commentedThanks for the tip. I want to avoid hacking core if at all possible, but this gives me another example to play with. Will report back on any progress...
TKS
Comment #3
buddaCan you not use Views with RSS argument selector. Then theme the View output if needed?
Comment #4
TKS commentedA very belated update on this -- just realized and never posted back on how we solved this problem.
The short answer: Hire someone who knows more than you do.... :) Dopry wrote a quickie module for us that overrides node/feed and passes it through the theme layer.
The module itself looks like this:
There's also a .install file, to make sure the module runs in the proper sequence:
And then in template.php, we now have the following override:
Hope that helps...
Comment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.