This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Developer » Fetching and sorting in PHP, using...
expandshrink

Fetching and sorting in PHP, using extended attribute filter

Fetching and sorting in PHP, using extended attribute filter

Thursday 13 May 2010 5:08:55 pm - 2 replies

Hi all,

I am looking for example of making subtree fetch from PHP (for example by using eZContentObjectTreeNode::subTreeByNodeID) while using extended attribute filter and sorting on arbitrary sql statement (that is generated by extended attribute)

I tried something like this, but it does not seem to work:

$nodes = eZContentObjectTreeNode::subTreeByNodeID(  
    array(     'MainNodeOnly' => true,
        'ClassFilterType' => 'include',
        'ClassFilterArray' => array( $class_identifier ),
        'SortBy' => array( 'my_sql_var', true ),
        'ExtendedAttributeFilter' => hash( 'id', 'myExtFilter', 'params', hash( 'var_1', $var_1 ))
        ), 
    $parent_node_id 
    );

Thnx.

Modified on Thursday 13 May 2010 5:15:49 pm by Igor Vrdoljak

Thursday 13 May 2010 11:10:20 pm

Hi Igor

The equivalent of the template hash operator is the array PHP function. (the hash PHP function exists but it's not what you expect here). So I guess the correct code is the following (depending on the extended attribute filter you use) :

$nodes = eZContentObjectTreeNode::subTreeByNodeID( array( 'MainNodeOnly' => true,
                                                          'ClassFilterType' => 'include',
                                                          'ClassFilterArray' => array( $class_identifier ),
                                                          'SortBy' => array( 'my_sql_var', true ),
                                                          'ExtendedAttributeFilter' => array( 'id' => 'myExtFilter',
                                                                                              'params', array( 'var_1' => $var_1 ) ) ),
                                                   $parent_node_id );

Cheers !

Modified on Thursday 13 May 2010 11:12:17 pm by Damien Pobel

Saturday 15 May 2010 11:16:26 am

Hi Damien,

Thanx for the tip, it was the case of using hash arrays in PHP.

Params attribute also has to be in a hash array, so the final working snippet is:

eZContentObjectTreeNode::subTreeByNodeID( array('MainNodeOnly' => true,
  'ClassFilterType' => 'include',
  'ClassFilterArray' => array( $class_identifier ),
  'SortBy' => array( 'my_sql_var', true ),
  'ExtendedAttributeFilter' => array( 'id' => 'myExtFilter',
    'params' => array( 'var_1' => $var_1 ) ) ),
  $parent_node_id );
expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from