Forums / Developer / Writing new modules

Writing new modules

Author Message

Tristan Koen

Thursday 12 June 2003 2:18:05 am

I have scoured the forums, contributed docs, etc but can't find any really useful documentation on writing new modules.

I have tried going through the source code to figure out what to do, but it is very obscure.

All I have managed to figure out so far is:
1. Create a directory for the new module under /kernel/.
2. Create a file named module.php that contains a set of associative arrays that do various things.
I can't find any docs that describe these arrays, their parameters and what they do though.
e.g. $ViewList has a whole bunch of elements including: 'functions', 'default_navigation_part', 'single_post_functions', 'post_action_parameters', 'post_actions', 'script' and 'params'. Where are these documented.
What role do the $ClassID, $ParentClassID, $SectionID, $Status, $Assigned, $Node, $Subtree and $FunctionList arrays play?
3. Add files for the various views of the module under the /kernel/mymodule/ directory. The output of each of these views is passed to the $Result associative array...
4. Admin interface can then be extended to accomodate the new function by supplying a set of new default and override templates.

I think I have the basics (please comment on any mistakes above), but it isn't enough to do anything useful at the moment.

Also, all of the existing code for the module views contains the following two lines:
$http =& eZHTTPTool::instance();
$Module =& $Params["Module"];

Why are they there? If I comment them out, the modules still work fine. I know what the first line does, but why is it there if the modujle doesn't need it? The second line is a complete mystery to me...

Perhaps I am missing something in the docs? I will be eternally grateful to anyone that can shed some light here.

Sven Ryen

Thursday 12 June 2003 6:48:53 am

Hi Tristan!

We're in the same boat, it seems... I just started looking into modules today.

The file:
    /lib/ezutils/classes/ezmodule.php
should provide you with info on how modules are executed.

Please post your findings here. I promise to do the same.

Sven Ryen

Thursday 12 June 2003 7:48:32 am

FWIW, I think the reccomended way of adding a module is to add an entry to either ModuleRepositories[] or ExtensionRepositories[] under [ModuleSettings] in module.ini.append.

Then, place your modules in the folder you add to ModuleRepositories[] or in a "modules/" subfolder inside the folder you add to ExtensionRepositories[].

So, if you need to add a module named "bar", you could add the file:
   /foo/modules/bar/module.php
and add "ExtensionRepositories[]=foo" to the file
   /settings/override/modules.ini.append

Sven Ryen

Thursday 12 June 2003 8:43:20 am

Note that some modules also have functions and operations, which are ? respectively ? defined in the files
    /kernel/<module_name>/function_definition.php
and
    /kernel/<module_name>/operation_definition.php

The functions and operations are executed by the files:
    /lib/ezutils/classes/ezmodulefunctioninfo.php
    /lib/ezutils/classes/ezmoduleoperationinfo.php

Sergiy Pushchin

Thursday 12 June 2003 11:19:56 am

1. You are right.
2. Yes you are right.
ViewList is set of views defined for module, for each view you define:
'functions' - to which functions user should have access to to be able to execute this view. so it used for permission system.
'default_navigation_part' - navigation part which should be active when this view is executed.
'single_post_functions' and 'post_action_parameters' is a mapping between post variables (buttons, input fields) and actions inside view.
'script' - php file which should be executed when user acceses this view.
'params' - params in url. for example url is 'content/edit/29658/1', content is modeule name, edit is view name and the last two numbers will be interpreted as parameters for the view.
"params" => array( "ObjectID", "EditVersion", 'EditLanguage' )
So inside a view you will be able to access
$Params["ObjectID"]; and $Params["EditVersion"]; they will get values 29658 and 1 by order. $Params["EditLanguage"]; will be empty since in url we have only two parts after view name separated with '/'
3.You are right.

about these two lines
$http =& eZHTTPTool::instance();
If you don't use it, it is not nessesary to put this line in view file

$Module =& $Params["Module"];
The same with this one. $Module object you get in this line gives you a lot of control on execution. For example you can use http redirections using its methods.

 

Sven Ryen

Thursday 12 June 2003 11:49:26 am

There's also documentation on module handling here:

http://www.ez.no/sdk/ezutils/view/module_handling/

Bruce Morrison

Thursday 12 June 2003 4:19:46 pm

Will someone from eZ please correct me if I'm wrong, but the proper way to add modules is via the extention system. This way you do not have to modify any ezpublish code only the configuration files. Upgrades a whole lot simpler if you use this method!

I looked at the ezRSS and glossary contributions as well as the online editor which all work this way and used these to create my own modules as extentions. These examples proved invaluable.

Cheers
Bruce
designIT

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Sven Ryen

Friday 13 June 2003 1:33:49 am

Ineed.

Extensions allows you to gather actions, datatypes, design, eventtypes, modules, settings and probably more in one convenient folder, improving portability and upgradability.

eZ debug

Timing: Jan 18 2025 10:28:57
Script start
Timing: Jan 18 2025 10:28:57
Module start 'content'
Timing: Jan 18 2025 10:28:57
Module end 'content'
Timing: Jan 18 2025 10:28:57
Script end

Main resources:

Total runtime0.2091 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0106 589.0391180.8438
Module start 'content' 0.01060.0152 769.8828101.8359
Module end 'content' 0.02590.1831 871.7188532.2344
Script end 0.2090  1,403.9531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00401.9083200.0002
Check MTime0.00170.8101200.0001
Mysql Total
Database connection0.00080.372510.0008
Mysqli_queries0.133063.60861410.0009
Looping result0.00150.69581390.0000
Template Total0.182287.110.1822
Template load0.00120.585910.0012
Template processing0.180986.535210.1809
Override
Cache load0.00080.370710.0008
Sytem overhead
Fetch class attribute can translate value0.00060.268810.0006
XML
Image XML parsing0.00030.148710.0003
General
dbfile0.01617.7036200.0008
String conversion0.00000.004230.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs