Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I have a complex use case with workbench_moderation and revisions that made me want to do "fancy stuff" on nodes before they get updated by Feeds. Things like disabling generation of a new revision, etc...
After a long investigation, I found a KISS method that relies on hook_node_prepare(). However, that means I need a little information to determine in my custom module (and potentially contribs) that the node is being prepared by Feeds, so I made this simple patch that puts the FeedsSource object inside the node before running it into prepare. As an example, I could implement:
<?php
mymodule_node_prepare($node) {
if (isset($node->feeds_source) && $node->feeds_source->id == 'source_foo') {
// Do not generate new revision for this update.
$node->revision = FALSE;
}
}
?>
Comment | File | Size | Author |
---|---|---|---|
feeds_hook_node_prepare.patch | 709 bytes | franz | |
Comments
Comment #1
dealancer CreditAttribution: dealancer commentedNice solution.
Instead we can provide invoke of additional hook in feeds module before node preparation call. That will allow to better document this new feature.
Comment #2
franzIn that case, I'd add 2 hooks:
1 - When node is loaded/built and before filling the values
2 - After filling the values and before node_prepare
Comment #3
twistor CreditAttribution: twistor commentedI'm not sure what other "fancy stuff" you are doing, but we should have an option to disable revision generation.
I realize this issue is really old, just trawling through the issues.