Closed (outdated)
Project:
Views (for Drupal 7)
Version:
6.x-2.16
Component:
feed displays
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
16 Apr 2010 at 16:49 UTC
Updated:
26 Jul 2017 at 10:38 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
merlinofchaos commentedTo which link are you referring? Feeds have many links, including links to the feed and links from the feed.
Comment #2
nancydruThe node URL which the end-user will click to come back to our site to read the whole article. I can correctly alter this in blog/xxx/feed, but it's not working for taxonomy/term/xxx/feed, which is being produced by the Views version of taxonomy/term.
Comment #3
merlinofchaos commentedHmm. That's weird because for normal RSS feeds, assuming you haven't modified the style in use on the feed, should use the standard method of producing RSS. See includes/modules/node/views_plugin_style_node_rss.inc (and the preprocess, where most of the work is done, is in modules/node.views.inc). There's nothing too out of the ordinary there. I can't think why nodeapi might not be getting called.
Might want to check caching? Anonymous caching covers RSS.
Comment #4
nancydruActually I stand corrected on that, it does appear that nodeapi is called, and even that build_mode is set to RSS, however, the modified $node->link field is being ignored. Yes, I see that I am changing it. And during my testing here, I am user/1.
I am doing this in hook_nodeapi(..., 'view',...):
As I mentioned, this is fine with blog/xxx/feed.
Comment #5
johnpitcairn commentedThe problem, as far as I see it, is in views_plugin_row_node_rss.inc.
The $item object is created immediately after the hook_nodeapi "alter" op is invoked, and the $item->link and $item->title properties are added then.
Then hook_nodeapi "rss item" op is invoked, and array elements returned from that will be added to $item->elements.
So there's no way for hook_nodeapi "rss item" to alter the title or link. And in hook_nodeapi "alter", I don't think we can tell if the node is being built for RSS, ie messing with things there will have unfortunate side-effects.
I propose a small modification of views_plugin_row_node_rss.inc: move the addition of the $item->title and $item->link elements to AFTER hook_nodeapi "rss item" is invoked. I don't think that would affect anything else.
Patch against 6.x-2.10 attached.
Comment #6
nicks commentedAs I just pointed out on this issue: http://drupal.org/node/174359 this change will only allow you to set the title, and not the link, as the link is not built from a property of the $node object. It may be possible to achieve a workaround by changing that, or by overriding the views-view-row-rss.tpl.php template, but it may require some hacking around. I suspect that finding a solution that can be patched into the views module itself will be difficult.
Comment #7
johnpitcairn commentedYeah, sorry - I was mostly interested in changing the title.
Since we're patching the views plugin, I wonder if adding a custom hook would be a decent solution for you? Something like (untested):
Then implement that hook in your own module to generate and return the link.
Comment #8
dawehnerThats the same code from drupal core. The item is also there.
Comment #9
johnpitcairn commentedYes, but this is the Views issues queue. The issue is how to modify the link in an RSS feed item generated by a Views feed display - not how to do so in core's RSS feeds.
Comment #10
dawehnerSure sure.
The reason why i posted it, was that we shouldn't change the code from the existing one in drupal.
Comment #11
strangeways commentedHere's some code to alter an RSS item's title, creator, and link via a custom module.
Don't forget to clear your cache so that the preprocessor function gets recognized.
Comment #12
strangeways commentedOops, array_merge expects an array of arrays, so in hook_nodeapi() use this line instead:
And the preprocessor can be replaced with this:
Comment #13
johnpitcairn commentedNice, no need to patch the views plugin. I was overlooking the availability of $node->build_mode in the "alter" op.
Comment #14
dawehnerSo this is fixed?
Comment #15
yan commentedThanks for the snippet in #11 & #12, strangeways. It works, but only when I remove the
break;from the preprocessor function or put it inside the if-statement above it. i.e. like this:Comment #16
nancydru@dereine: My customer will not allow such a convoluted solution. The most they will accept is needing the
case 'rss item':in hook_nodeapi(). And with at least 6 feeds so far, I'm certainly disinclined to clone the preprocess code that many times. We really need something cleaner.Comment #17
nancydru$vars['row'] contains Array ( [0] => Array ( [key] => comments [value] => http://drupal6b/noel_yuhanna/10-05-17-sybase_acquisition_sap_great_move#comments ) [1] => Array ( [key] => category [value] => Application Development [attributes] => Array ( [domain] => http://drupal6b/application_development ) ) [2] => Array ( [key] => category [value] => Database [attributes] => Array ( [domain] => http://drupal6b/category/database ) ) [3] => Array ( [key] => category [value] => ERP [attributes] => Array ( [domain] => http://drupal6b/category/erp ) ) [4] => Array ( [key] => category [value] => SAP [attributes] => Array ( [domain] => http://drupal6b/category/sap ) ) [5] => Array ( [key] => category [value] => Sybase [attributes] => Array ( [domain] => http://drupal6b/category/sybase ) ) [6] => Array ( [key] => pubDate [value] => Mon, 17 May 2010 17:00:18 +0000 ) [7] => Array ( [key] => dc:creator [value] => Noel Yuhanna [namespace] => Array ( [xmlns:dc] => http://purl.org/dc/elements/1.1/ ) ) [8] => Array ( [key] => guid [value] => 4368 at http://drupal6b [attributes] => Array ( [isPermaLink] => false ) ) )
Note, no isset($element['link'])
Comment #18
nancydruAh, it helps to spell "rss item" correctly. This seems to be working now. I'm just not going to tell the customer how it got fixed. Now I have to make sure no other feeds are broken.
Comment #19
nancydruComment #21
zerolab commented@dawehner, @strangeways
first off thank you for the alternate solution. However, in some cases doing the preprocess is too much (deh, clients!). Sorry for reopening this, but the 3.3 code solves this in a simple manner ( see line 156 ) and allows a simple change in
hook_nodeapias seen hereI am attaching a patch against 2.16 that moves the
$item->link = url()bit before the node hooks are called and instead relies on$item->link = $node->linkand could be considered a partial backport from Views 3.3Comment #22
mustanggb commented