Tuesday 12 July 2005 6:12:01 am
Hmm, yes, actions seems to be very much missing from the documentation. If you have created any "create new object here" buttons in your templates, then you have already used actions. But now you will have to write your own action. This is a rather technical explanation, for more help you can try studying /kernel/content/action.php, as well as the html code for create object here forms and the like. Start by creating an extension. In content.ini.append.php for the extension, add: [ActionSettings]
ExtensionDirectories[]=extensionName
Then create file extensions/extensionName/actions/content_actionhandler.php. Here's an example of how it should look:
<?php
function extensionName_ContentActionHandler(&$module, &$http, &$objectID) {
if ($http->hasPostVariable("ActionRemoveSticky")) {
$object =& eZContentObject::fetch($objectID);
$object->remove(false, $_POST["NotisNodeID"]);
}
return;
}
?>
This example actually does exactly what you want to, I believe. It simply deletes the node with the NodeID given through the post variable. To call on your action, you then use a form. Method should be post, action should point to index.php/content/action, I believe, and the submitbutton should have the name attribute set to the name used in the code, in the example above this would be ActionRemoveSticky. You should also have a hidden field, with name="ContentObjectID" and value, well, the object id of the object you want to affect. To send the Node ID as well, simply add a new hidden field, with whatever name you want, and you can access it like I did above in the PHP code, using $_POST. Good luck!
/David
|