3

How can I do this? Force nodes created by Feeds module to be published even if regular nodes are unpublished by default.

4

Implement hook_nodeapi() for the 'presave' operation to set the node status to published if there is a new one created by Feeds:

function MODULE_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op === 'presave' && empty($node->nid) && !empty($node->feeds_node_item)) {
    $node->status = 1;
  }
}
  • I'm going to try this – Matthew Hui Aug 4 '11 at 21:07
2

Making nodes published is not a problem, the question is how are we going to tell the nodes created by Feeds. The quickest options are

  1. a separate node type for imported content, or
  2. a hidden field that only gets set via Feeds mapping

Assuming none of the quick solutions would fit your scenario, the only actual way to tell Feed-created nodes is the feeds_node_item. After importing a node, it will contain a record for the node, with nid column set to the node id.

Making use of the Rules module, the whole trick is just a matter of an Execute custom PHP code for condition to check if the record is there for the newly created node:

Add new rule

Event: After saving new content

Add a condition

Select the condition to add: Execute custom PHP code

PHP code

<?php
$a = db_fetch_array(db_query("select count(*) c from {feeds_node_item}
                              where nid = %d", array($node->nid)));
return $a['c'] != 0;
?>

Add an action

Select an action to add: Publish content

1

I've done something similar to expose the user status as a mapper; see the patch proposed in Add user status to FeedsUserProcessor, which would be similar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.