eZ Community » Forums » Developer » How to do a fetch with PHP
expandshrink

How to do a fetch with PHP

How to do a fetch with PHP

Thursday 09 March 2006 11:20:16 am - 4 replies

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

Thursday 09 March 2006 11:30:57 am

Hi Felix,

Use eZContentObjectTreeNode

$parentNodeID = 123;

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

Modified on Thursday 09 March 2006 11:31:40 am by Ɓukasz Serwatka

Thursday 09 March 2006 12:24:25 pm

Hi Lukasz,

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

happy.gif Emoticon Felix

Thursday 09 March 2006 12:42:45 pm

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);
}

Thursday 09 March 2006 1:07:49 pm

Hi again,

great! Thank you very much!

Felix

expandshrink

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

36 542 Users on board!

Forums menu