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.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 03:21:52
Script start
Timing: Jan 19 2025 03:21:52
Module start 'layout'
Timing: Jan 19 2025 03:21:52
Module start 'content'
Timing: Jan 19 2025 03:21:53
Module end 'content'
Timing: Jan 19 2025 03:21:53
Script end

Main resources:

Total runtime1.1793 sec
Peak memory usage4,096.0000 KB
Database Queries63

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 589.1563152.6250
Module start 'layout' 0.00540.0031 741.781339.4453
Module start 'content' 0.00851.1693 781.2266617.7109
Module end 'content' 1.17770.0015 1,398.937520.1563
Script end 1.1792  1,419.0938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.2565160.0002
Check MTime0.00120.1046160.0001
Mysql Total
Database connection0.00070.056710.0007
Mysqli_queries1.071590.8588630.0170
Looping result0.00070.0584610.0000
Template Total1.145597.120.5728
Template load0.00210.176820.0010
Template processing1.143496.963820.5717
Template load and register function0.00010.012610.0001
states
state_id_array0.00070.057510.0007
state_identifier_array0.00240.200020.0012
Override
Cache load0.00220.18801880.0000
Sytem overhead
Fetch class attribute can translate value0.00070.058120.0003
Fetch class attribute name0.00160.137260.0003
XML
Image XML parsing0.00080.068320.0004
class_abstraction
Instantiating content class attribute0.00000.001470.0000
General
dbfile0.00090.0735160.0001
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
30content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
25content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 64
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs