Friday 19 August 2011 5:53:00 am
By : Thiago Campos Viana
In this post I will show how to create the minimum content action extension.
The 'content/action' view is commonly used to process forms - while eZ Publish does a lot of validation, you may want to customise this.
Let's create our folder structure inside extension folder first:
Then let's define that this extension has actions by creating the minaction/settings/content.ini.append.php file:
<?php /* #?ini charset="utf-8"? * [ActionSettings] ExtensionDirectories[]=minaction */ ?>
Also we need to create the php action handler for this extension, so we create the minaction/actions/content_actionhandler.php file:
<?php function minaction_ContentActionHandler(&$module, &$http, &$objectID ) { if ($http->hasPostVariable("hello" ) ) { echo $http->postVariable("hello"); eZExecution::cleanExit(); } return; } ?>
In administrator user interface, click 'setup' tab->'extensions' menu, select 'minaction', click button 'Apply Changes', click button 'Regenerate autoload arrays for extensions'. Clear the cache.
Finally you need to edit one template somewhere and create a form with one field named 'hello', as our extension check if the submited form has one variable named 'hello':
<form action={"content/action"|ezurl} method="post"> <input name="hello" type="submit" value="Hello Action!" /> </form>
Then when you submit the form, the php code of our extension will be called some time, and we will check if the submited form to the content/action view has some variables and do something.
Timing: | Jan 17 2025 23:51:01 |
Script start | |
Timing: | Jan 17 2025 23:51:01 |
Module start 'layout' | |
Timing: | Jan 17 2025 23:51:01 |
Module start 'content' | |
Timing: | Jan 17 2025 23:51:01 |
Module end 'content' | |
Timing: | Jan 17 2025 23:51:01 |
Script end |
Total runtime | 0.0852 sec |
Peak memory usage | 6,144.0000 KB |
Database Queries | 43 |
Checkpoint | Start (sec) | Duration (sec) | Memory at start (KB) | Memory used (KB) |
---|---|---|---|---|
Script start | 0.0000 | 0.0059 | 588.0547 | 152.6406 |
Module start 'layout' | 0.0059 | 0.0027 | 740.6953 | 39.5000 |
Module start 'content' | 0.0086 | 0.0747 | 780.1953 | 361.1328 |
Module end 'content' | 0.0833 | 0.0018 | 1,141.3281 | 15.7031 |
Script end | 0.0851 | 1,157.0313 |
Accumulator | Duration (sec) | Duration (%) | Count | Average (sec) |
---|---|---|---|---|
Ini load | ||||
Load cache | 0.0033 | 3.8608 | 15 | 0.0002 |
Check MTime | 0.0012 | 1.4217 | 15 | 0.0001 |
Mysql Total | ||||
Database connection | 0.0007 | 0.8663 | 1 | 0.0007 |
Mysqli_queries | 0.0358 | 42.0793 | 43 | 0.0008 |
Looping result | 0.0003 | 0.3863 | 41 | 0.0000 |
Template Total | 0.0509 | 59.8 | 2 | 0.0255 |
Template load | 0.0024 | 2.8201 | 2 | 0.0012 |
Template processing | 0.0485 | 56.9399 | 2 | 0.0242 |
Template load and register function | 0.0001 | 0.1195 | 1 | 0.0001 |
states | ||||
state_id_array | 0.0008 | 0.9934 | 1 | 0.0008 |
state_identifier_array | 0.0011 | 1.2716 | 2 | 0.0005 |
Override | ||||
Cache load | 0.0020 | 2.2900 | 22 | 0.0001 |
Sytem overhead | ||||
Fetch class attribute name | 0.0020 | 2.3737 | 3 | 0.0007 |
class_abstraction | ||||
Instantiating content class attribute | 0.0000 | 0.0084 | 3 | 0.0000 |
General | ||||
dbfile | 0.0008 | 0.8854 | 10 | 0.0001 |
String conversion | 0.0000 | 0.0092 | 4 | 0.0000 |
Note: percentages do not add up to 100% because some accumulators overlap |
Usage | Requested template | Template | Template loaded | Edit | Override |
---|---|---|---|---|---|
1 | node/view/full.tpl | blog_entry/full.tpl | extension/community_design/design/suncana/override/templates/blog_entry/full.tpl | ||
2 | content/datatype/view/ezxmltext.tpl | <No override> | extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tpl | ||
1 | content/datatype/view/ezxmltags/link.tpl | <No override> | design/standard/templates/content/datatype/view/ezxmltags/link.tpl | ||
6 | content/datatype/view/ezxmltags/paragraph.tpl | <No override> | extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tpl | ||
2 | content/datatype/view/ezxmltags/li.tpl | <No override> | design/standard/templates/content/datatype/view/ezxmltags/li.tpl | ||
2 | content/datatype/view/ezxmltags/ul.tpl | <No override> | design/standard/templates/content/datatype/view/ezxmltags/ul.tpl | ||
3 | content/datatype/view/ezxmltags/literal.tpl | <No override> | extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tpl | ||
1 | content/datatype/view/ezkeyword.tpl | <No override> | extension/community_design/design/suncana/templates/content/datatype/view/ezkeyword.tpl | ||
1 | print_pagelayout.tpl | <No override> | extension/community/design/community/templates/print_pagelayout.tpl | ||
Number of times templates used: 19 Number of unique templates used: 9 |
Time used to render debug report: 0.0001 secs