How can I group by Values of Combo box field ?

Author Message

Pierre SCALFATI

Wednesday 18 February 2009 8:42:06 am

Hello,

I've created a class which contains a combo box field (allowing only one choice) and I would like to dispay the data of my class by values of this combo box.

How can I do ?

exemple: My combo box contains the names of magazines and I would like to display the data for each magazine like that:

>>>Financial Times
blablabla...

>>>The Economist
blablabla...

Pierre SCALFATI

Thursday 19 February 2009 5:25:57 am

OK, I found by myself. I was trying to ask people if they knew a powerful template command which would have make it easier than what I did but anyhow, my solution is a more traditional programming way but it works.

First of all I've been sorting my data by values of my combo :

{def $rubriques = fetch('content', 'list', hash('parent_node_id', $node.node_id,
'sort_by',array( 'attribute', true(),'rankings/journal' ), 'depth', 0))}
Then I've created a variable to store the values of my combo and to which I gave a default value:
{def $saved_journal='-1'}

and then in the template I've read the first value of my combo which has been read in the {foreach $rubriques as $r} loop of my content and I've compared it to the $saved_journal value

if different, that means that I'm on a new value of News paper (journal) and I must display the Newspaper name, if not, I display the rest of data because that means that I'm always on the same name of Newspaper (journal).

Then I save the current value of newspaper before closing my foreach loop:

{def $saved_journal=$r.data_map.journal.data_text}

It works fine.

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 20:49:34
Script start
Timing: Jan 18 2025 20:49:34
Module start 'layout'
Timing: Jan 18 2025 20:49:34
Module start 'content'
Timing: Jan 18 2025 20:49:34
Module end 'content'
Timing: Jan 18 2025 20:49:34
Script end

Main resources:

Total runtime0.0160 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 588.0469152.6406
Module start 'layout' 0.00570.0033 740.687539.4766
Module start 'content' 0.00900.0047 780.164189.2578
Module end 'content' 0.01370.0023 869.421930.3047
Script end 0.0159  899.7266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002716.9179140.0002
Check MTime0.00127.2375140.0001
Mysql Total
Database connection0.00084.982710.0008
Mysqli_queries0.003018.807130.0010
Looping result0.00000.111910.0000
Template Total0.001811.210.0018
Template load0.00106.121310.0010
Template processing0.00085.008110.0008
Override
Cache load0.00074.373810.0007
General
dbfile0.00031.732580.0000
String conversion0.00000.055240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs