eZ Community » Forums » Developer » Module Development - Please help!!!

Module Development - Please help!!!

Module Development - Please help!!!

Tuesday 11 November 2003 8:16:32 am - 1 reply


I am busy writing a new module and have run into an issue that I just can't solve. I am hoping that someone on this forum can give me a hint as to where I'm going wrong.

I have based my code on the Module Tutorial in the documentation section. The difference is that I get my data from a SOAP datasource rather than the database.

The problem seems to stem from my use of the templating system.

My code is as follows:

BEGIN list.php------------------------------------------>

$Module= &$Params['Module'];
$viewParameters = array('upc' => $Params['upc']);

include_once( "kernel/common/template.php"blunk.gif Emoticon;
$tpl = &templateInit();
$tpl->setVariable('view_parameters', $viewParameters);

$Result['content'] = $tpl->fetch("design:mymodule/product.tpl"blunk.gif Emoticon;
$Result['path'] = array(array('url' => '/mymodule/product',
'text' => 'Products'));


END mymodule.php------------------------------------------>

I then have another file called function_definition.php that looks as follows:

BEGIN function_definition.php------------------------------------------>


$FunctionList = array();
$FunctionList['list'] = array('name' => 'list',
'operation_types' => array('read'),
'call_method' => array('include_file' => 'extension/warehouse/modules/mymodule/productfunctioncollection.php',
'class' => 'ProductFunctionCollection',
'method' => 'fetchItem'),
'parameter_type' => 'standard',
'parameters' => array(array('name' => 'upc',
'required' => true,
'default' => false)));


END function_definition.php------------------------------------------>

This part appears to be correct and works as I would expect it to.

I then have a simple 'test' file called productfunctioncollection.php. It just returns a dummy result array (for test purposes). It looks as follows:

BEGIN productfunctioncollection.php------------------------------------------>


class ProductFunctionCollection
function ProductFunctionCollection()

function &fetchItem($upc)
return array('result' => &$upc);


END productfunctioncollection.php------------------------------------------>

I then have a simple template file mymodule/product.tpl that looks as follows:

BEGIN product.tpl------------------------------------------>
View Parameters: {$view_parameters.upc} <br />
{let test = fetch('mymodule','list',hash('upc','123')}

No matter what I do, the value of $test is always 1, instead of being an array. The value for the upc is correct.

If I put print() statements in the code, it all executes correctly. The problem seems to be where the array with the 'result' element is returned to the templeting system. I have tried everyting and cannot get this to work.

I have to assume that the array I am returning in &fetchItem() needs some other elements?

I anyone can give me a hand here, I will really appreciate it. I have been stuck on this problem for 2 days now and am getting desperate.


Tuesday 11 November 2003 11:17:06 am

Declare the type of the variable being input into the function:

'parameters' => array(array('name' => 'upc',
'type' => 'integer',
'required' => true,
'default' => false)));

Do you want to return an array from the integer you input? '123' becomes '1,2,3'? From your code it seems like you are simply passing a number to the php and back again.



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

36 542 Users on board!

Forums menu

Proudly Developed with from