Hi all,

I think that I need some help to solve my issue...

I am working on a drupal project based on drupal 6 ; and i want to send a mail to a specific adress when a new story is posted on my site.

Actually, with the action & trigger modules integrated in drupal6, i can :
* create an action to send a email with the content of the node
* associate this action with the trigger 'creation of a new content'

But what i need is to send a email ONLY when new story is created ! Because i also use a lot of ather content type (page, book page, event...) ; and i don't want to send email for other content type...

Do you have a solution ?

Thanks :)

Comments

alan d.’s picture

Rules is the evolution of workflow-ng, which will easily help.

Till then, you could get a custom module to hook into the nodeapi to manually trigger an email.

<?php
function MYMODULE_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'insert':
      if($node->type == '') {
        // insert email code here
      }
  }

}
?>

Alan Davison
www.caignwebs.com.au

Alan Davison
julienbras’s picture

Seems what i need yes ...

Need to wait :(

Thanks for the info ;)

AlexisWilke’s picture

Look at the Rules module.

koyama’s picture

I just want to say to other beginners like me that I didn't find the rules documentation pages helpful for getting a quick overview.

Using rules module, when you add a new rule at admin/rules/trigger/add
you first have to choose the for "Event": Node > After saving new content
At this point it looks like the rule isn't for a specific content type, but after saving the rule, you come to the next page where you can impose extra condition that the node is of a certain type.

I found this 5 minute video about rules module helpful:
http://blip.tv/file/4281259

rusdvl’s picture

How do I trigger an action when a comment is left on a particular content type? I've got it to trigger when that content type gets created edited or deleted... but I cant figure out when a comment gets added, deleted or edit only on that content type.....

vm’s picture

did you take a moment to read this thread? specifically the comment just above your own? ;)

rusdvl’s picture

im creating a module and i need it to do in within it.... not using other modules.... so i need to know what the code would be...

vm’s picture

it helps a great deal to know that from the start. I've no answer for you however, if you reverse engineer the rules module you may find the code you need.

rusdvl’s picture

I've figured it out. If someone else needs to know this, here is the code:

/**
 * Implementation of hook_comment().
 */
function MYMODULE_comment(&$a1, $op) {
	switch ($op) {
		case 'delete':
			$node = node_load($a1[nid]);
			$nid  = $node->nid;
			if($node->type == 'your_content_type') {
				// do stuff here
			}
		break;
		case 'update':
			$node = node_load($a1[nid]);
			$nid  = $node->nid;
			if($node->type == 'your_content_type') {
				// do stuff here
			}
		break;
		case 'insert':
			$node = node_load($a1[nid]);
			$nid  = $node->nid;
			if($nodeType == 'your_content_type') {
				// do stuff here
			}
		break;
	}
}
alan d.’s picture

I would really recommend the Rules module for non-programmers. But there are similar hooks for user, node, and taxonomy if you do require a code based solution


Alan Davison