Forums / Developer / How to do a fetch with PHP

How to do a fetch with PHP

Author Message

Felix Laate

Thursday 09 March 2006 2:20:16 am

Hi all,

I want to fetch the newest object of a certain class in a certain folder, and I need to do it with PHP as it's part of a module.

Let's say I have a content class "letter" with ID=21, and I have a bunch of objects of this class that are published under a certain folder. Now I need to fetch the newest one.

Any help is helpful and appreciated!

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Łukasz Serwatka

Thursday 09 March 2006 2:30:57 am

Hi Felix,

Use eZContentObjectTreeNode

$parentNodeID = 123;

$objects =& eZContentObjectTreeNode::subTree(  array(
'ClassFilterType' => 'include',
'ClassFilterArray' => array( 'letter' ),
'SortBy' => array( 'published', false ),
),
$parentNodeID
);

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Felix Laate

Thursday 09 March 2006 3:24:25 am

Hi Lukasz,

thanx, that did the trick.. now I only need to figure out how to get the attributes of the object.. any advice?

:-) Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Łukasz Serwatka

Thursday 09 March 2006 3:42:45 am

Loop throw $objects array

foreach( $objects as $object )
{
    $dataMap =& $object->attribute( 'data_map' );
   
    //image attribute
    $image = $dataMap['image']->content();
 
    // email attribute
    $email = $dataMap['email']->content();
    var_dump($dataMap);
}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Felix Laate

Thursday 09 March 2006 4:07:49 am

Hi again,

great! Thank you very much!

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com