3

I'm trying to fetch content using php. But my code seems not to work. I'm using ezcontentobjecttreenode::subtree function but it displays this error:

Using $this when not in object context in /home/quejadore/site/kernel/classes/ezcontentobjecttreenode.php on line 2032

Here is my code.

$params = $nodes =& eZContentObjectTreeNode::subTree( array( 
    'Depth' => 3,
    'SortBy' => array( 'published', false),
    'Limit' => 3,
    'ClassFilterType' => 'include',
    'ClassFilterArray' => array('article_v3'),
    'Attribute_filter' => array(array('article_v3/on_newsletter', '=',true))));

$nodes =& eZContentObjectTreeNode::subTree( $params, 21312);

Anyone can help please? Thanx in advance

I have now edited my code(even if it still not working yet).Here is what i have now:

$params = array('Depth' => 3,
            'Limit' =>1,
            'IgnoreVisibility' => true,
            'Limitation' => array(),
            'ClassFilterType' => 'include',
            'ClassFilterArray' => array('article_v3'),
            'AttributeFilter' => array(array('article_v3/on_newsletter','=',true)));


$obj = new eZContentObjectTreeNode;
$nodes = $obj->subTree($params, 21312);
$dataMap =$nodes->attribute( 'data_map' );
$image =& $dataMap['image']->content();
$list =& $image->aliasList();
var_dump( $list['original']['url'] );
You
  • 39
  • 5
  • You're calling a method statically, and it's NOT a static method... you need to instantiate an eztree object and call the method properly `$foo = new EzWhatever; $foo->subtree(...)` – Marc B Jan 26 '15 at 16:35
  • THanx for that quick answer Marc. It seems to work.but my array is NULL. And i'm sure that the params meet at least 50 objects :| – You Jan 26 '15 at 16:46
  • Try `AttributeFilter`, not `Attribute_filter` – foobar Jan 26 '15 at 23:20
  • It looks like to be the good parameter but it still NULL. – You Jan 27 '15 at 08:54

2 Answers2

1

So i found the solution.Here's my code :

$params = array(
            'Depth' => 3,
            'AsObject' => true,
            'Limit' =>3,
            'SortBy' => array( 'published', false),
            'IgnoreVisibility' => true,
            'Limitation' => array(),
            'ClassFilterType' => 'include',
            'ClassFilterArray' => array('article_v3'),
            'AttributeFilter' => array(array('article_v3/on_newsletter', '=', true)));

$nodes = eZContentObjectTreeNode::subTreeByNodeID($params, 21312);

Thanx to all

You
  • 39
  • 5
0

If you need to know how to use fetch functions in PHP, have a look at the template fetch functions reference, in your case : https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/tree

Replace parameters by their 'classified' version : attribute_filter becomes AttributeFilter, class_filter_type becomes ClassFilterArray, etc... Remember that eZ Publish takes care of the visibility and role permissions, even if you are using the PHP API. If you want to ignore this, use 'IgnoreVisibility' => true in your parameters array.

Also, I'm not sure of what you are trying to do but you don't need to call this method by reference using &

foobar
  • 926
  • 6
  • 21