Sebastiaan van der Vliet
|
Thursday 14 April 2005 3:40:38 am
Hi,
I'm not sure about fetching everything from a tree, but to fetch all publications owned by the current user you could use the following function:
function fetchPublicationList( $class_id, $offset, $limit )
{
$userID = eZUser::currentUserID();
$publicationList = & eZPersistentObject::fetchObjectList( eZContentObject::definition(),
null, array( 'owner_id' => $userID,
'status' => EZ_VERSION_STATUS_PUBLISHED,
'contentclass_id' => $class_id ),
null, array( 'length' => $limit, 'offset' => $offset ),
true );
return array( 'result' => &$publicationList );
}
Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.
|
Sebastiaan van der Vliet
|
Thursday 14 April 2005 5:41:40 am
Hi, The best solution would be to integrate this functionality as a template plugin in your site. However, for a number of reasons I choose to modify the kernel. Among others because I wanted to set up a "http://mysite/content/publication_list" or "Contributions" page that displays an overview all contributions (owned) by the user. This is what I did: 1. To /kernel/content/ezcontentfunctioncollection.php I added:
function fetchPublicationList( $class_id, $offset, $limit )
{
$userID = eZUser::currentUserID();
$publicationList = & eZPersistentObject::fetchObjectList( eZContentObject::definition(),
null, array( 'owner_id' => $userID,
'status' => EZ_VERSION_STATUS_PUBLISHED,
'contentclass_id' => $class_id ),
null, array( 'length' => $limit, 'offset' => $offset ),
true );
return array( 'result' => &$publicationList );
}
2. To /kernel/content/function_definition.php I added:
$FunctionList['publication_list'] = array( 'name' => 'publication_list',
'operation_types' => array( 'read' ),
'call_method' => array( 'include_file' => 'kernel/content/ezcontentfunctioncollection.php',
'class' => 'eZContentFunctionCollection',
'method' => 'fetchPublicationList' ),
'parameter_type' => 'standard',
'parameters' => array( array('name' => 'class_id',
'type' => 'integer',
'required' => true),
array( 'name' => 'offset',
'type' => 'integer',
'required' => false,
'default' => false ),
array( 'name' => 'limit',
'type' => 'integer',
'required' => false,
'default' => false ) ) );
3. Inside the template I call the function as follows:
{section loop=fetch( 'content', 'can_instantiate_class_list' )}
{let publication_list=fetch('content', 'publication_list', hash(class_id, $:item.id, limit, 100, offset, 0))}
{section loop=$publication_list sequence=array(bgdark,bglight)}
[..etc...]
{/section}
{/let}
{/section}
The code above displays all classes, but you can restrict it to only articles. It is not a real elegant solution, in terms of upgrading etc.
Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.
|