eZ Community » Projects » SortObjectsOperators

SortObjectsOperators

Content objects/nodes sorting template operators extension.

» Visit project page    » Project members    » Reviews

Latest forum activity - Visit project's forums page

Monday 11 July 2011 10:35:05 am

Not to remove the usefullness of this extension. However, I would recommend sorting in sql instead of in template, if possible. It's in general a lot faster and cleaner.

Ref.: http://ezpedia.org/ez/extended_sort

Thursday 09 February 2012 12:35:22 am

Hey, great extension, thank you very much!

Arne Bakkeb√ł is right with extended_sort I think, but I like this one =)

Maybe you are interested to add my little extension to yours to sort by price:

<code>

case 'sort_key':

$objectA = self::getObjectAttributeSortKey( $objectA, $attributeName );

$objectB = self::getObjectAttributeSortKey( $objectB, $attributeName );

$objectAAttributeValue = '';

$objectBAttributeValue = '';

// if price is gt... (sort_key_int)

if ( $objectA > $objectB ) {

// Making ObjectA to be less than ObjectB

// Jumping to comparing function

$objectAAttributeValue = 'a';

$objectBAttributeValue = 'b';

} else {

$objectAAttributeValue = 'b';

$objectBAttributeValue = 'a';

}

break;

</code>

<code>

public static function getObjectAttributeSortKey( $object, $attributeName ) {

$attribute = self::getObjectAttribute( $object, $attributeName );

//sort_key_int sometimes has a difference from 1, maybe a bug...

//return $attribute->SortKeyInt;

$Price = sprintf ( '%01.2f', $attribute->DataFloat );

$PriceInt = (int) str_replace(',','',str_replace('.','',str_replace(' ','',$Price)));

return $PriceInt;

}

</code>

<code>

{def $sorted_children = get_sorted_objects( $children_arr, array(

array(

false(),

array( 'sort_key', 'price' )

)

))}

</code>

best regards

scrieler

Thursday 09 February 2012 9:05:20 am

I think you were talking about "typed" sorting, right? Maybe it is worth to add attribute value's type specificator. Will think how to manage that.

Thanks for idea happy.gif Emoticon

Members - Visit project's team page
Real name:
Alex Kozeka
Country:
Ukraine 
#Posts:
11
Project reviews - See all reviews

No review yet.