2

It is a question that always gets answered by "use rules module." Unfortunately, this site depends heavily on a few actions and triggers already, and a migration is not in order.

Are there trigger-addons, tricks or code to make a trigger on creation of a certain node-type only?

2

Rules and core triggers/actions can co-exist. If it can easily be done in Rules, then why not use both. You then won't have to migrate.

1

I think the easiest way is to create your own action module:

/**
 * Implements hook_action_info().
 */
function mymodule_action_info() {
  return array(
    'mymodule_myaction_action' => array(
      'type' => 'node',
      'description' => t('Does something to a node'),
      'configurable' => FALSE,
      'hooks' => array(
        // When this action is called.
        'nodeapi' => array('presave', 'insert', 'update', 'view'),
        'comment' => array('insert'),
      ),
    ),
  );
}

/**
 * Implements hook_action().
 */
function mymodule_myaction_action($node, $context) {
  // If the node type is different from FAQ, returns and does nothing.
  if ($node->type == 'faq') {
    // Do something here.
  }
}
  • The best thing in this way is that, you can call this action function in a hook_nodeapi or hook_node_OP. My favorite technique :) – AyeshK Jul 26 '12 at 2:51

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.