Sunday 09 March 2008 3:23:57 am
Hi, I'm running eZ Publish 4.0.0 and need to write an extension for our site. What I've got so far is taken mostly from the manual, the online articles, and lots of code reading and debugging (to better understabnd what happens behind the scenes). I can create design, templates, translations and template operators ok. Where I'm stuck is setting up a new fetch function (which is right now the core of my current work). Ok, what did I do: Created an extension, with module directory, a directory for my module, and thus I've got this now in extension/xxldapusers/modules/xxpartners:
[arno@xx xxpartners]$ ls function_definition.php ldap.php
<?php
# the following include fixes a possible bug:
# the named include_file is apparently never included
# A.L.
include('extension/xxldapusers/modules/xxpartners/ldap.php');
$FunctionList=array();
$FunctionList['partners'] = array( 'name' => 'partners',
'operation_types' => array( 'read' ),
'call_method' => array( 'include_file' => 'extension/xxldapusers/modules/xxpartners/ldap.php'
,
'class' => 'xxldapfetch',
'method' => 'FetchPartners' ),
'parameter_type' => 'standard',
'parameters' => array( array( 'name' => 'country',
'type' => 'string',
'required' => false ) )
);
?>
This file, as shown above, works <b>once</b> after clearing the cache. The next run, I get a fatal error with this information in the apache's error log:
[Sun Mar 09 09:48:48 2008] [error] [client 91.96.some.ip] PHP Fatal error: Class xxldapfetch' not found in /var/www/ez/var/ezwebin_site/cache/template/compiled/xx_partnerlist-9840f7bd50f98f56b322336088b46bd9.php on line 404, referer: http://ez.xx.com/eng/Partners/Find-a-xx-Partner/Partners-list
I understand that, for some reason, the file with the actual function definition is not really included in the cached version. If I leave out the include from the function_definition.php, I get an error stating that the class for the defined function call could not be found. The latter is not really astonishing after I looked into the source of lib/ezutils/classes/ezmodulefunctioninfo.php as there, only the function_definition.php file is included, but the referenced include_file is never read.
What I conclude:
- function_definition.php is not working as expected; the named include_file is not included at all. I found the instructions at http://ez.no/de/layout/set/printarticle/developer/articles/an_introduction_to_developing_ez_publish_extensions (German), by the way. The same construct is found in kernel/layout/function_definition.php so I expect it to be supported, by the way. - including other php files is not easily done as caching seems not to handle file inclusions. How do I others handle these problems? Thanks, Arno
|