I add the action to work flow changes. From (creation) to submitted (I created this status). The action effect on a node. And i got the empty object.<br><br><div class="gmail_quote">On Tue, Jul 13, 2010 at 9:46 PM, Vandyk, John K [ENT] <span dir="ltr">&lt;<a href="mailto:jvandyk@iastate.edu">jvandyk@iastate.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">That does not look like an implementation of hook_action_info(). For an example implementation, see<br>

<br>
<a href="http://api.drupal.org/api/function/hook_action_info/6" target="_blank">http://api.drupal.org/api/function/hook_action_info/6</a><br>
<br>
It looks like you are actually writing an action. In that case, the first parameter is populated by the native object that the action is working on. For example, if you are triggering an unpublish action when a node is edited, the object that you are working on is a node, and the trigger system will send the node object along to the action call as the first parameter.<br>
</blockquote><div>The problem is that the first parameter is empty. <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
However, if you want to do something crazy like unpublish a node when a comment is submitted, you are acting on a comment object, not a node object. </blockquote><div>My object is a node. <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
If you run an unpublish node action in that case, the trigger system will expend a little effort trying to make sure that the unpublish-a-node action (which works on nodes) gets a node. See<br>
<br>
<a href="http://api.drupal.org/api/function/trigger_comment/6" target="_blank">http://api.drupal.org/api/function/trigger_comment/6</a><br>
<a href="http://api.drupal.org/api/function/_trigger_normalize_comment_context/6" target="_blank">http://api.drupal.org/api/function/_trigger_normalize_comment_context/6</a><br>
<br>
Since some actions can be called in multiple contexts, you will see them doing gyrations like this:<br>
<br>
<a href="http://api.drupal.org/api/function/system_message_action/6" target="_blank">http://api.drupal.org/api/function/system_message_action/6</a><br>
<br>
The short answer is, ask yourself whether your action will ever be used in a weird context, and if you might have to pluck the $node from the $context or do a node_load() from some information in the context that could lead you to the node.<br>

<div><div></div><div class="h5"><br>
On Jul 13, 2010, at 12:52 AM, icerain wrote:<br>
<br>
&gt; When i implement hook_action_info(), i found the first para *$node* is empty.<br>
&gt; My question is<br>
&gt; function mymodule_myaction_action(&amp;$node, $context = array()) {<br>
&gt;     $node = $context[&#39;node&#39;]; // should this line be added?<br>
&gt; ...<br>
&gt; }<br>
&gt; Or something else error?<br>
&gt; --<br>
&gt; A decathlon Drupal developer &amp; programmer<br>
&gt; <a href="http://blog.eood.cn/" target="_blank">http://blog.eood.cn/</a><br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>A decathlon Drupal developer &amp; programmer<br><a href="http://blog.eood.cn/">http://blog.eood.cn/</a><br>