Share » Forums » Developer » Defining "methods" or "custom...

Defining "methods" or "custom actions" for content classes?

Defining "methods" or "custom actions" for content classes?

Wednesday 07 December 2005 12:09:19 am - 3 replies

Modified on Wednesday 07 December 2005 12:15:01 am by Deane Barker

Author Message

Ɓukasz Serwatka

Wednesday 07 December 2005 12:27:30 am

It is possible to create custom actions in eZ publish. By default it comes with several like, creating new content, editing, collecting information and more.

You can place new actions in extension/mynewextension/actions/content_actionhandler.php

You will have to override content.ini in your extension and add
extension/mynewextension/settings/content.ini.append.php

[ActionSettings]
ExtensionDirectories[]=mynewextension

extension/mynewextension/actions/content_actionhandler.php

function name have to start with extension name, other ways it will not work

function mynewextension_ContentActionHandler( &$module, &$http, &$objectID )
{
    if( $http->hasPostVariable("CustomAction") )
    {
        //your custom action goes here
    }
}

In tpl you will need define form:

<form method="post" action="content/action">
    <input type="submit" name="CustomAction" value="Custom action" />
    <input name="ContentObjectID" type="hidden" value="102" />
</form>

ContentObjectID have to be included in POST.

For more examples look in to /kernel/content/action.php. I think you can re-use some code.

Hope it will help you.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Deane Barker

Wednesday 07 December 2005 5:55:12 am

Wonderful, thank you. I remember seeing that one line of template code ages ago, but I could never find any documentation on it. This is fantastic.

Andrew K

Tuesday 18 July 2006 6:59:37 am

Yup. That's what I'm looking for!
Thanks.

--Andrew

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu