Forums / Developer / Sorting by Object relation : custom operator

Sorting by Object relation : custom operator

Author Message

patrice brun

Friday 30 April 2010 8:27:12 am

Hello
I want to sort objects on an attribute 'object relationship'. So I created a 'custom operator(orderByObjectRelation)'. At the end of my php code I do a 'return $ tabOrderok'. I call it this way in my template:
(Def $newcat = orderByObjectRelation ($ cats))
($newcat | attribute ('show'))
I get the following error message:
Error: eZTemplate: foreach Apr 30 2010 5:05:48 p.m.
Missing / malformed array to iterate through.
In my php code I do a var_dump my object and all seems ok.
Why do you think my table is not returned on well?
Thank you

Jérôme Vieilledent

Saturday 01 May 2010 2:39:32 am

Hi Patrice

I'm not sure I understand your problem... Would you mind show your code please ?

By the way, this might not be the right way to do such a sort for a fetch. You should take a look in extended attribute filters. Indeed, with them you can add new columns to the SQL statement produced by the fetch and then use them in sort_by ;).

http://ez.no/doc/ez_publish/technical_manual/4_x/reference/modules/content/fetch_functions/list

Abdelkader RHOUATI

Monday 03 May 2010 2:09:53 am

Hi Patrice,

You gave the wrong answer to your needs, and I invite you to see the solution proposed by Jérôme.

No matter for your problem, in your operator template, try to use :


return array( 'result' => $tabOrderok );

Regrads.

Abdelkader RHOUATI

Blog (french) : http://arhouati.com
----
Extension arh_jdebug : EzDebug using jquery