Forums / Developer / what the wrong with this module ?!

what the wrong with this module ?!

Author Message

Selmah Maxim

Saturday 09 August 2003 3:57:27 am

userinfofunctioncollection.php :

<?

include_once( 'kernel/error/errors.php' );

class userInfoFunctionCollection
{

function userInfoFunctionCollection()
{
}

function &fetchUserByID($user_id)
{
echo "[$user_id]";
include_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );
$user =& eZUser::fetch($user_id);
if ( $user === null )
return array( 'error' => array( 'error_type' => 'kernel',
'error_code' => EZ_ERROR_KERNEL_NOT_FOUND ) );
return array( 'result' => $user );
}

}

?>

function_definition.php :

<?php
$FunctionList = array();
$FunctionList['user_info'] = array( 'name' => 'user_info',
'operation_types' => array( 'read' ),
'call_method' => array( 'include_file' => 'extension/mymodules/modules/userinfo/userinfofunctioncollection.php',
'class' => 'userInfoFunctionCollection',
'method' => 'fetchUserByID' ),
'parameter_type' => 'standard',
'parameters' => array( array( 'name' => 'user_id',
'type' => 'integer',
'default' => false,
'required' => true ) ) );
?>

module.php:

<?
$Module = array( "name" => "User Info",
"variable_params" => true );
$ViewList = array();

?>

now in the dubeg I get :

Missing parameter 'user_id' for function 'user_info' in module 'userinfo'

I call it from template like this :
{fetch(userinfo,user_info,hash(10))|attribute(show)}

any help plz ?!

Tony Wood

Saturday 09 August 2003 6:34:36 am

Hi,

Can you replace echo "[$user_id]"; with eZDebug::writeDebug( $user_id, "Userid " );

Does it $user_id contain anything?

Tony Wood : twitter.com/tonywood
Vision with Technology
Experts in eZ Publish consulting & development

Power to the Editor!

Free eZ Training : http://www.VisionWT.com/training
eZ Future Podcast : http://www.VisionWT.com/eZ-Future

Selmah Maxim

Saturday 09 August 2003 7:02:11 am

Hi Tony ...

I had stop this module , now am writeing new module for listing based on doc. tutorial .. the problem now is just looping and at the end i got page not found .. here is the code :

module.php :
-------------------
<?php

$Module = array( 'name' => 'Companies' );

$ViewList = array();
$ViewList['list'] = array(
'script' => 'list.php',
"unordered_params" => array( "offset" => "Offset" ) );
?>
----------------
list.php:
-----------------
<?php

$Module =& $Params['Module'];

$Offset = $Params['Offset'];
if ( !is_numeric( $Offset ) )
$Offset = 0;

$viewParameters = array( 'offset' => $Offset );

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

$Result = array();
$Result['content'] = $tpl->fetch( "design:companies/list.tpl" );
$Result['path'] = array( array( 'url' => false,
'text' => 'Companies' ),
array( 'url' => false,
'text' => 'List' ) );
?>
--------------------------
function_definition.php :
--------------------------
<?php

$FunctionList = array();
$FunctionList['list'] = array( 'name' => 'list',
'operation_types' => array( 'read' ),
'call_method' => array( 'include_file' =>
'extension/q8b2b/modules/companies/companyiesfunctioncollection.php',
'class' => 'CompaniesFunctionCollection',
'method' => 'fetchList' ),
'parameter_type' => 'standard',
'parameters' => array( array( 'name' => 'offset',
'required' => false,
'default' => false ),
array( 'name' => 'limit',
'required' => false,
'default' => false ) ) );
?>
------------------------
companyiesfunctioncollection.php :
-------------------------------
<?php

include_once( 'extension/q8b2b/modules/companies/companies.php' );

class CompaniesFunctionCollection
{

function CompaniesFunctionCollection()
{
}

function &fetchList( $offset, $limit )
{
$parameters = array( 'offset' => $offset,
'limit' => $limit );
$lista =& Companies::fetchListFromDB( $parameters );

return array( 'result' => &$lista );
}

}
?>
----------------------------
companies.php
---------------------------
<?

include_once( 'kernel/classes/ezpersistentobject.php' );
include_once( "lib/ezdb/classes/ezdb.php" );
include_once( "lib/ezutils/classes/ezdebug.php" );

class Companies extends eZPersistentObject
{

function Companies( $row )
{
$this->eZPersistentObject( $row );
}

function &definition()
{

$db =& eZDB::instance();

$asObject = true;

$query = "SELECT
ezcontentobject.id,
ezcontentobject.name,
ezcontentobject.owner_id,
ezcontentobject.published,
ezcontentobject.modified
FROM
ezcontentobject
WHERE
ezcontentobject.contentclass_id = '15'
ORDER BY ezcontentobject.id";

$class_name = "companies";
$rows =& $db->arrayQuery( $query );
return eZPersistentObject::handleRows( $rows, $class_name, $asObject );

}

function &fetchListFromDB( $parameters = array() )
{
return Companies::handleList( $parameters, false );
}

function &handleList( $parameters = array(), $asCount = false )
{
$parameters = array_merge( array( 'as_object' => true,
'offset' => false,
'limit' => false ),
$parameters );
$asObject = $parameters['as_object'];
$offset = $parameters['offset'];
$limit = $parameters['limit'];
$limitArray = null;
if ( !$asCount and $offset !== false and $limit !== false )
$limitArray = array( 'offset' => $offset,
'length' => $limit );

return eZPersistentObject::fetchObjectList( Companies::definition(),
null, null, null, $limitArray,
$asObject );
}

}

?>

I think the error is with $class_name ... I get no dubeg to check the error .. to know what the wrong here :(

any help please ?

Tony Wood

Saturday 09 August 2003 7:35:06 am

If its any help, i start with a stripped down version. just a couple of lines. Once i get that working, i add to it.

Tony Wood : twitter.com/tonywood
Vision with Technology
Experts in eZ Publish consulting & development

Power to the Editor!

Free eZ Training : http://www.VisionWT.com/training
eZ Future Podcast : http://www.VisionWT.com/eZ-Future

Selmah Maxim

Sunday 10 August 2003 12:38:32 am

Thx Tony .. but no need for it in actual time.