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

eZ Community » Forums » Developer » Custom Attribute Filter Sorting

Custom Attribute Filter Sorting

Custom Attribute Filter Sorting

Wednesday 31 October 2012 12:50:14 pm - 3 replies

I have implemented a custom attribute filter however I need to sort on some of these attributes as well.

I can't see any functionality to do this and adding and ORDER BY clause seems to be out of the question due to the final AND clause when I return my $sqlCond

$sqlCond .= ' ezcontentobject_tree.contentobject_id IN (' . $sql . ' ) AND ';

Is custom attribute sorting possible and if so can any provide any examples or places to look for an example in ez publish

Wednesday 31 October 2012 2:53:53 pm

Yes, you can use any name generated by the "columns" element in your extended attribute filter in your fetch's sort_by parameter. By that I mean...

function createSqlParts( $params )
    $columns = ', (<logic here>) as my_sort_field';
    return array( 'columns' => $columns, 'tables' => '', 'joins' => '' );

Then in your fetch function:

 'sort_by', array(
                           array( 'my_sort_field', false() )
                          ,array( 'name', true() )

Wednesday 31 October 2012 3:00:08 pm

I think the custom filters provided by ezstarrating are a good example for this

Thursday 01 November 2012 8:30:16 am

Thanks for the responses, worked like a charm with this info


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

36 542 Users on board!

Forums menu

Proudly Developed with from