If the parent feed imports a node (the form/node to input the feed URL, not the feeds importer) that is unpublished, I'd like to have it (the feed URL) not be included in the cron schedule to update/import the feed items. How is this done? For example, a user submits a feed, but the administrator needs to verify it before publishing, and importing it.
-
Have you had any luck figuring this one? I tried this with the default (RSS) Feed Importer and it seemed to work as expected -- it didn't import when the feed node was unpublished.– Jan TomkaCommented Aug 12, 2011 at 11:29
-
Hmm, that's odd. One of my feed importer is configured to use Common Syndicate Parser and the other one uses QueryPath Parser. I confirmed that the feed node (parent) is unpublished. Did you see the note that it's importing feeds on a cache flush -- is that odd or normal? It shouldn't do that regardless of status, right? I'm on a local so cron isn't set up yet.– hellomobeCommented Aug 12, 2011 at 23:01
-
1The linked article has much better information, even sample code. Please consider adding that to the question here.– berkesCommented Sep 9, 2011 at 11:49
1 Answer
It looks like, when a node is saved, Feeds module starts importing the feed from that node.
function feeds_node_insert($node) {
// Source attached to node.
feeds_node_update($node);
if (isset($node->feeds) && $importer_id = feeds_get_importer_id($node->type)) {
$source = feeds_source($importer_id, $node->nid);
// Start import if requested.
if (feeds_importer($importer_id)->config['import_on_create'] && !isset($node->feeds['suppress_import'])) {
$source->startImport();
}
// Schedule source and importer.
$source->schedule();
feeds_importer($importer_id)->schedule();
}
}
There is an option in the importer's setting page called Import on submission. If you uncheck this box, hopefully your feed won't be imported. Feeds maintainer still need to make changes in feed_cron() so that it won't fetch the unpublished nodes.
While you wait for a better fix from module maintainers, you can quickly fix this code by changing the first if statement to add $node->status==1 condition as follows:
if ($node->status==1 && isset($node->feeds) && $importer_id = feeds_get_importer_id($node->type))