Share » Forums » Developer » what the wrong with this module ?!

what the wrong with this module ?!

what the wrong with this module ?!

Saturday 09 August 2003 3:57:27 am - 4 replies

Author Message

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.

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

36 542 Users on board!

Forums menu