DataType: Matrix with fixed values

Author Message

Albe Terra

Thursday 24 July 2008 1:50:58 am

Hi!
I need to create a class with a particular datatype. I need to manage information from a matrix, where I want to fix the possible values.

The idea is to have a table with "Regions" and "Cities". During the creation of a new instance of the class the user will select a Region from a small set of values, and as a consequence the city (from the set of cities of the selected Region).

Is it possible to obtain this result with eZMatrix? Or with object relations?

Thanks, Albe

Robert Ledoux

Monday 04 August 2008 10:05:30 am

Hello

have you find a soution for this problem :
http://ez.no/developer/forum/developer/datatype_matrix_with_fixed_values

thanks for your answer.

chap

Gabriel Finkelstein

Monday 04 August 2008 4:07:22 pm

You could make 2 classes: Region and City. Each City has an object relation with a Region. You store regions and cities in 2 different folders. And in the edit template of your class, you add an objectrelation for region and another for city.
Both relation input fields should be dropdowns. The "Region" dropdown:

<select name="region" onchange="changeCities(this.options[this.selectedIndex].value)">
{foreach $regions as $region}
   <option value={$region.id}>{$region.name}</option>
{/foreach}
</select>

The "City" dropdown:

<select name="city">
{foreach $cities as $city}
   <option value={$city.id} region={$city.data_map.region.content.id}>{$city.name}</option>
{/foreach}
</select>

Or something like that. And then make a javascript function called changeCities(), which hides the cities from the dropdown, that don't belong to the selected region.

Of course, there's no kind of validation, so a user could actually pick a region and a city that doesn't belong to that region.

Maybe there's some kind of "Related Dropdowns" datatype somewhere.

Albe Terra

Tuesday 05 August 2008 7:04:32 am

Thanks a lot!
I will try with this solution!

If other solutions come to your mind, please tell me :)

Thanks again for your help,
Albe!

Piotrek Karaƛ

Tuesday 05 August 2008 11:49:40 am

With little effort, you can make a custom datatype operate on any custom data model (db table set), so if you do not need the regions/cities to be objects, you could backup Gabriel's idea with some lightweight 1:n db tables, and even provide UI for managing those tables in the administration interface. That would then work as one coherent attribute of a class.

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

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 16:12:11
Script start
Timing: Jan 18 2025 16:12:11
Module start 'layout'
Timing: Jan 18 2025 16:12:11
Module start 'content'
Timing: Jan 18 2025 16:12:12
Module end 'content'
Timing: Jan 18 2025 16:12:12
Script end

Main resources:

Total runtime0.6930 sec
Peak memory usage4,096.0000 KB
Database Queries67

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 589.0547152.6250
Module start 'layout' 0.00560.0023 741.679739.4609
Module start 'content' 0.00780.6838 781.1406636.7266
Module end 'content' 0.69160.0013 1,417.867212.1563
Script end 0.6929  1,430.0234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4492160.0002
Check MTime0.00130.1910160.0001
Mysql Total
Database connection0.00060.083710.0006
Mysqli_queries0.631491.1093670.0094
Looping result0.00080.1103650.0000
Template Total0.655694.620.3278
Template load0.00220.315020.0011
Template processing0.653494.286520.3267
Template load and register function0.00010.020510.0001
states
state_id_array0.00140.201910.0014
state_identifier_array0.00190.273820.0009
Override
Cache load0.00190.2767330.0001
Sytem overhead
Fetch class attribute can translate value0.00070.105040.0002
Fetch class attribute name0.00150.218670.0002
XML
Image XML parsing0.00140.199140.0003
class_abstraction
Instantiating content class attribute0.00000.002470.0000
General
dbfile0.00100.1454230.0000
String conversion0.00000.001040.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
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
9content/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
2content/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: 25
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs