Hello,
I'm trying to create an action, but I think I'm missing something obvious. The Writing Actions tutorial (http://drupal.org/node/156754) says that I can create a new action like this:
function yourmodule_action_info() {
return array(
'yourmodule_action_node_set_author' => array(
'#label' => t('Set the content author'),
'#arguments' => array(
'node' => array('#entity' => 'node', '#label' => t('Content')),
'author' => array('#entity' => 'user', '#label' => t('User, which is set as author')),
),
'#module' => t('Node'),
),
);
}
So I change "your_module" to "profile" (since I have profile module installed), and put this in template.php:
function profile_action_info() {
return array(
'profile_action_node_set_author' => array(
'#label' => 'Test',
'#arguments' => array(
'node' => array('#entity' => 'node', '#label' => t('Content')),
'author' => array('#entity' => 'user', '#label' => t('User, which is set as author')),
),
'#module' => t('Node'),
),
);
}
Now when I want to add an action, "Test" under Node doesn't show up. What am I missing here?
Thanks,
Andrey.
Comments
Comment #1
mr.andrey commentedI just changed the code to:
... since I thought that _action_node_set_author might already be taken. It still doesn't show up.
I also tried setting it to:
... in case '#arguments' was limiting the visibility in some kind of way.
I'm trying to do this "on node update" event. Does that have something to do with it?
Any thoughts?
Thanks,
Andrey.
Comment #2
fagohm, the code looks good, so I don't know what's wrong. Perhaps the template.php is included to late? Try putting it into a module file.
Comment #3
mr.andrey commentedThat's what I ended up doing. It works fine in a module, but I couldn't get it to work in the template.php.
Thanks,
A.
Comment #4
fagoComment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.