Grouping by an attribute

Author Message

Pablo C. Vergara Castro

Tuesday 14 September 2004 6:26:29 am

Hi to all.

I would like to know the way to make fetch that simply return objects grouped by a certain attribute. For example, I have several objects of a class "publication" that have an attribute "date", and what I want it is to know the way to extract the dates that are different and in addition to solely be able to count them.

{... 1999 ...},{... 2000 ...},{... 1999 ...},{... 2001 ...},{... 2000 ...} ===> {1999},{2000},{2001}, (3 attributes)

Sven Anderson

Wednesday 15 September 2004 3:20:25 am

If it's an existing arry, have a look here:
http://www.ez.no/community/forum/developer/sorting_an_array

If you get your array by the fetch functions, have a look here:
http://www.ez.no/ez_publish/documentation/development/libraries/ez_template/operators/data_fetch

hoping this helps,

greets,
Sven

Pablo C. Vergara Castro

Wednesday 15 September 2004 3:46:52 am

Thanks Sven but

a) The first link is really too old and the only answer that it gives is that ez can't sort.

b) I know the steps to sort data using fetch function but I don't want to sort, the think I want to do is Grouping by.

Sort:

{... 1999 ...},{... 2000 ...},{... 1999 ...},{... 2001 ...},{... 2000 ...} ===>{... 1999 ...},{... 1999 ...},{... 2000 ...},{... 2000 ...},{... 2001 ...}

Group:

{... 1999 ...},{... 2000 ...},{... 1999 ...},{... 2001 ...},{... 2000 ...} ===> {1999},{2000},{2001}

I begin to think that at the moment ezpublish cannot group data :_(.

Ekkehard Dörre

Wednesday 15 September 2004 5:28:36 pm

in 3.3 blog template archive_navigatorbar.tpl there is a "group_by":

{let show_week=false()
     item_node_id=50
     month_list=fetch( content, tree, hash( parent_node_id, $item_node_id,
                                            class_filter_type, include,
                                            class_filter_array, array( 'log' ),
                                            attribute_filter, array( and, array( 'published', '>=',
                                                                                  maketime( 0, 0, 0, $today_info.month, 1, $today_info.year ) ),
                                                                          array( 'published', '<=',
                                                                                  maketime( 23, 59, 59, $today_info.month | inc, 0, $today_info.year ) ) ),
                                            group_by, array( "published", "day" ),
                                            as_object, false() ) )
     month=$month_list|month_overview( 'published', maketime( 0, 0, 0, $today_info.month, $today_info.day, $today_info.year ),
                                        hash( current, maketime( 0, 0, 0, $today_info.month, $today_info.day, $today_info.year ),
                                              current_class, 'selected',
                                              link, concat( "content/view/full/", $item_node_id ),
                                              month_link, true(), year_link, true(), day_link, true(),
                                              next, hash( link, concat( "content/view/full/", $item_node_id ) ),
                                              previous, hash( link, concat( "content/view/full/", $item_node_id ) )  ) )}

other tread:
http://ez.no/community/forum/setup_design/group_by_parameter_in_fetch_function

Greetings, ekke

http://www.coolscreen.de - Over 40 years of certified eZ Publish know-how: http://www.cjw-network.com
CJW Newsletter: http://projects.ez.no/cjw_newsletter - http://cjw-network.com/en/ez-publ...w-newsletter-multi-channel-marketing

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 19 2025 07:02:47
Script start
Timing: Jan 19 2025 07:02:47
Module start 'layout'
Timing: Jan 19 2025 07:02:47
Module start 'content'
Timing: Jan 19 2025 07:02:48
Module end 'content'
Timing: Jan 19 2025 07:02:48
Script end

Main resources:

Total runtime1.3294 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0044 589.1563152.6250
Module start 'layout' 0.00440.0027 741.781339.4453
Module start 'content' 0.00711.3209 781.2266588.8359
Module end 'content' 1.32800.0013 1,370.062512.1641
Script end 1.3294  1,382.2266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.2266160.0002
Check MTime0.00120.0936160.0001
Mysql Total
Database connection0.00070.054810.0007
Mysqli_queries1.275695.9505620.0206
Looping result0.00070.0505600.0000
Template Total1.296397.520.6482
Template load0.00190.142020.0009
Template processing1.294497.367520.6472
Template load and register function0.00030.021210.0003
states
state_id_array0.00220.164710.0022
state_identifier_array0.00110.081120.0005
Override
Cache load0.00160.1228300.0001
Sytem overhead
Fetch class attribute can translate value0.00070.056230.0002
Fetch class attribute name0.00150.113650.0003
XML
Image XML parsing0.00070.053930.0002
class_abstraction
Instantiating content class attribute0.00000.000850.0000
General
dbfile0.00140.1089160.0001
String conversion0.00000.000640.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
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.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: 19
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs