Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
node_feed()
seem to be still using the old node building API
So it's also the only place where we are calling hook_node_alter()
(please see #367214: hook_node_alter almost disappeared ? for more details on that one) and Fields or any additions made in the node building hooks never make it to the feed items.
Comment | File | Size | Author |
---|---|---|---|
#6 | node_feed-449718.patch | 18.93 KB | AmrMostafa |
#4 | node_feed-449718.patch | 16.05 KB | AmrMostafa |
#2 | node_feed-449718.patch | 3.42 KB | AmrMostafa |
#1 | node_feed-449718.patch | 3.61 KB | AmrMostafa |
Comments
Comment #1
AmrMostafa CreditAttribution: AmrMostafa commentedPatch attached. It depends on #449614: "read more" gone (node.module is still using hook_link for that) for the read more link.
This patch also changes something from the current (and also in D6) node_feed() behavior in that it includes the node links. This actually happens by default, since links are now part of the node content structure and so it gets included in the rendered content.
We could unset 'links' to retain the old behavior where links where not included in the feed, but why, this is a great feature because modules can easily check
node->build_mode == NODE_BUILD_RSS
and add only links they wish to be included with the node item in the feed. However, it's a bug that modules which provide links do not make this check, like taxonomy and comment modules who always set links with little or no checking for the build mode. I prefer that we handle these checks in other issues for those respective modules.Comment #2
AmrMostafa CreditAttribution: AmrMostafa commentedBetter patch (gotten rid of "read more" cruft, this was taken care of using a build_mode check in #449614: "read more" gone (node.module is still using hook_link for that))
Comment #3
moshe weitzman CreditAttribution: moshe weitzman commentedLooks like a very nice cleanup. This brings fields back into RSS feeds as they are in D6 with CCK.
I think the existing hook_node_build_alter() suffices and we can deprecate
$extra = module_invoke_all('node_rss_item', $node);
. Modules that use that operation will use the alter hook along with the build mode.Comment #4
AmrMostafa CreditAttribution: AmrMostafa commentedNew patch, gets rid of
hook_node_rss_item()
as suggested in #3 but useshook_node_view()
instead ofhook_node_build_alter()
, I hope that is Ok, Moshe.Modules now have
rss_elements
andrss_namespaces
to act on atNODE_BUILD_RSS
.I also added the needed checks for modules to not add links to nodes when
$node->build_mode == NODE_BUILD_RSS
which takes care of #1 (3rd paragraph).Comment #6
AmrMostafa CreditAttribution: AmrMostafa commentedCouple of minor fixes, plus tests! :)
Comment #7
moshe weitzman CreditAttribution: moshe weitzman commentedThe patch got much bigger since #2. Is that really needed? This patch is fine as an interim status, but I really would love if alienbrain or other would take on #409750: Overhaul and extend node build modes
Comment #8
AmrMostafa CreditAttribution: AmrMostafa commentedHere is what this patch currently does:
NODE_BUILD_RSS
in modules which currently do not do this.hook_node_rss_item()
in favor ofNODE_BUILD_RSS
in which modules can add extra RSS elements or namespaces, with documentation. This is also consuming a considerable space in the patch2 and 3 are why the patch has grown bigger. But I think they are needed and are pretty simple in their logic.
I will try to get into #409750: Overhaul and extend node build modes when I get a chance. Build modes are definitely underutilized in core, but what's actually problematic is that they are not being checked in the node building hooks implemented by modules.
Comment #9
moshe weitzman CreditAttribution: moshe weitzman commented@alienbrain - it is true that the build modes are not checked ... hav you used cck in drupal6 - specifically the display fields tab? that lets the *admin decide* what fields should show up for each build mode. thats where we have to get to in core, IMO.
i will take another look at this patch.
Comment #10
moshe weitzman CreditAttribution: moshe weitzman commentedRan through the code once again and this really is an admirable modernization of our rss feeds. For example, field information may now be included in the item body (cck UI gives admin a lot of control here).
Comment #11
Dries CreditAttribution: Dries commentedI'm delegating this patch to Moshe. I will commit this patch (after a quick review) when Moshe thinks it is ready.
Comment #12
dww@Dries: Moshe said it's RTBC in #10. What more is there to delegate in #11, 25 hours later?
Comment #13
Dries CreditAttribution: Dries commentedOops, I had opened this issue on Friday night, and didn't bother to reload it since. As a result, I missed the most recent updates.
Reviewed and committed. Thanks!
Comment #14
yched CreditAttribution: yched commentedNote that this patch effectively got rid of the last invocation of hook_node_alter().
From #367214: hook_node_alter almost disappeared ? :
"In current HEAD it's only called from node_feed(). In D6 it was called for all node_view() - er, and apparently *not* from node_feed() :-)"
I don't know if the previous need for hook_node_alter() is now fully undertaken by some other new hook (hook_node_alter always confused me a little), but if so we should remove it from node.api.php :
Comment #15
dwwyched: that's a job for #367214: hook_node_alter almost disappeared ? not here. ;)
Comment #16
AmrMostafa CreditAttribution: AmrMostafa commentedI updated the upgrade docs accordingly.