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.

eZ debug

Timing: Jan 19 2025 00:12:49
Script start
Timing: Jan 19 2025 00:12:49
Module start 'content'
Timing: Jan 19 2025 00:12:51
Module end 'content'
Timing: Jan 19 2025 00:12:51
Script end

Main resources:

Total runtime1.2540 sec
Peak memory usage4,096.0000 KB
Database Queries200

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 587.7109180.8359
Module start 'content' 0.00741.1118 768.5469622.7891
Module end 'content' 1.11920.1345 1,391.3359341.3672
Script end 1.2537  1,732.7031 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.3206210.0002
Check MTime0.00150.1189210.0001
Mysql Total
Database connection0.00070.055410.0007
Mysqli_queries1.145391.33142000.0057
Looping result0.00200.15581980.0000
Template Total1.220497.320.6102
Template load0.00220.174720.0011
Template processing1.218297.143820.6091
Template load and register function0.00020.017610.0002
states
state_id_array0.00200.159210.0020
state_identifier_array0.00130.102920.0006
Override
Cache load0.00230.18491880.0000
Sytem overhead
Fetch class attribute can translate value0.00140.115630.0005
Fetch class attribute name0.00110.085160.0002
XML
Image XML parsing0.00080.067630.0003
class_abstraction
Instantiating content class attribute0.00000.001270.0000
General
dbfile0.00650.5150270.0002
String conversion0.00000.000630.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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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