Frage

I have a Drupal 7 site with a custom node type with a custom attachment field. After a (kind of this custom) node has been published, I got an e-mail with the help of Rules module. I would like to set up an another rule, which sends me an another e-mail, when somebody edits this node and uploads an attachment. Inside the mail, I want to see the full url to the uploaded file.

After a several test, I'm not able to insert the full path to the uploaded file. The [node:field-attachment:file] doesn't work at all. I'm able to insert (manually) the url where this file resides, but after I can not insert the file name (so even the filename would be enough for me).

So with the [node:field-attachment:file] I got an error: *Fatal error: Call to a member function value() on a non-object in /home/xxx/sites/all/modules/entity/entity_token.tokens.inc on line 297.*

Which is exactly this:

/**
 * Gets the token replacement by correctly obeying the options.
 */
function _entity_token_get_token($wrapper, $options) {

   if ($wrapper->value() === NULL) {
// Do not provide a replacement if there is no value.
return NULL;
}

With the [node:field-attachment], I'm getting the e-mail, but it contains this: You can download the file from here: Property 0

Which token should I use to get the url (or the filename) of the actually uploaded file when I edit the node?

War es hilfreich?

Lösung

2 solutions

1 - You can write a simple module that hooks the node submit and handle the URL there and then mail it.

2 - You can create an action in rules module to execute a custom PHP code. There you will get all details of node in $node. You can also send and email using drupal mail API

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top