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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 05:15:16
Script start
Timing: Jan 18 2025 05:15:16
Module start 'layout'
Timing: Jan 18 2025 05:15:16
Module start 'content'
Timing: Jan 18 2025 05:15:17
Module end 'content'
Timing: Jan 18 2025 05:15:17
Script end

Main resources:

Total runtime0.6402 sec
Peak memory usage4,096.0000 KB
Database Queries59

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 588.0469152.6406
Module start 'layout' 0.00660.0035 740.687539.4766
Module start 'content' 0.01000.6287 780.1641579.4766
Module end 'content' 0.63880.0014 1,359.640612.1250
Script end 0.6401  1,371.7656 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.4750160.0002
Check MTime0.00130.2052160.0001
Mysql Total
Database connection0.00130.201810.0013
Mysqli_queries0.585891.5109590.0099
Looping result0.00060.0963570.0000
Template Total0.609695.220.3048
Template load0.00200.311220.0010
Template processing0.607694.914420.3038
Template load and register function0.00020.036910.0002
states
state_id_array0.00080.119510.0008
state_identifier_array0.00080.125620.0004
Override
Cache load0.00170.2590280.0001
Sytem overhead
Fetch class attribute can translate value0.00070.112830.0002
Fetch class attribute name0.00170.259250.0003
XML
Image XML parsing0.00150.233930.0005
class_abstraction
Instantiating content class attribute0.00000.001750.0000
General
dbfile0.00110.1784230.0000
String conversion0.00000.001440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 8

Time used to render debug report: 0.0002 secs