Still don't working with Rules' actions
Antinoo - April 14, 2009 - 22:38
| Project: | |
| Version: | 6.x-2.3 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Using the Rules module, I've add a "Post to Twitter" action but the tokens (%node_url, %title, %teaser, and so on) are not replaced: on twitter.com, it's posted something like %title (%node_url).
Am I missing something?

#1
I've made some debug, but unfortunately I don't know exactly how actions (core action and rules actions) work.
Anyway, the problem is that when the
twitter_actions_set_status_action()function is called, its first parameter,$object, isNULL.This way,
$nodewill be empty, and then$variableswill not be merged with the%node_url,%titleand so on variables.Why is this happening?
I'm using the [Node] After saving new content event.
Is it because the Twitter action is not a Node action?
Any thought?
#2
Update. I've also created a new RuleSet with a "Content" argument and assigned it to the node created, but still doesn't work.
#3
Hi, this issue still appears on 6.x-2.6, making the twitter action not very usefull (only the site name is replaced).
Any update or alternative to generate automated twitter posts including the node title and node url and using the Rules module?
Thanks!
#4
Note that even if the %* variabled cannot be used, some php code can do the work instead.
For example, to output the node title and an url to the node in the twit (assuming you previously did a 'load content' action to load the node object, and provided a 'Machine readable variable name': $nd), write the following code in the 'Message' field of your 'Post a message to Twitter' action:
<?phpprint $nd->title . ' ' . url('node/' . $nd->nid, array('absolute' => true));
?>
=> This enabled me using this great module for my use-case!
#5
Sebo,
Thanks for that fix!
I tweaked it a bit to make it work with pathalias so we dont see node/nid but the pathalias
<?php$path = 'node/' . $nd->nid;
print url(drupal_get_path_alias($path), array('absolute' => true));
print " - ".$nd->title;
?>
Above automaticaly converts to tinyurl =)
#6
Tweaked it even some more, to strip the HTML tags. I as admin post my nodes with html turned on. So to delete the html use:
<?php$path = 'node/' . $nd->nid;
print url(drupal_get_path_alias($path), array('absolute' => true));
print " - ".strip_tags( $nd->body );
?>