Selection attribute, how to handle changes in options

Author Message

Karsten Jennissen

Friday 02 February 2007 2:39:42 am

Hi,

I have been using the selection datatype extensively in a class, some of them with quite a few options (30-40).

Is this a reasonable way to handle options?

How can I modify the options without breaking the database? E.g. I want to add options. However the options have to be displayed in alphabetical order. So if I add options, I mess up the internal numbering of options, right?

Any help is greatly appreciated.

Cheers,
Karsten

Karsten Jennissen

Sunday 04 February 2007 3:51:34 am

Anybody?

Claudia Kosny

Sunday 04 February 2007 2:27:47 pm

Hi Karsten

I think you would be better off using the enhanced selection http://ez.no/community/contribs/datatypes/enhanced_selection as this seems to handle changing options the way you need. Unfortunately this means writing a conversion script that maps your selection to the enhanced selection but from what I remember of the enhanced selection datatype this should not be to hard. The bigger problem might be to adapt the templates to the new datatype, especially since you use it so extensively.

If you need to stick with the selection datatype I would go through all the contentobjectattributes of type selection, fetch the data_text attribute (which stores the ids of the options), map the ids to their values and store the values in a separate, temporary table with the contentobjectattribute id as identifier. Also store the class attribute id so you know which selection this entry belongs to. Then update your class definition. Then go again through all contentobjectattributes, fetch their selection values from the temporary table, fetch the corresponding option ids from the new class definition and insert the ids back into the data_text of the attribute. You might have to publish the objects afterwards to make the changes public on the webpage.
So the script itself it not to complicated but it is pretty cumbersome if you make changes to the options often. It will also take a sweet while if you have a lot of objects.

Hopefully you will get some better ideas next week but that's all you can expect over the weekend :-)

Good luck

Claudia

Karsten Jennissen

Monday 05 February 2007 3:30:53 am

Thanks a million. Site is not live, yet, so I will try to recode class and templates.

Cheers,
Karsten

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

Main resources:

Total runtime0.7317 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0114 588.1563152.6563
Module start 'layout' 0.01140.0041 740.812539.5078
Module start 'content' 0.01550.7145 780.3203480.7422
Module end 'content' 0.73000.0017 1,261.062512.1094
Script end 0.7317  1,273.1719 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.5157160.0002
Check MTime0.00160.2136160.0001
Mysql Total
Database connection0.00180.243010.0018
Mysqli_queries0.670391.6076600.0112
Looping result0.00060.0856580.0000
Template Total0.687894.020.3439
Template load0.00260.349720.0013
Template processing0.685293.637820.3426
Template load and register function0.00020.030910.0002
states
state_id_array0.00090.126210.0009
state_identifier_array0.00100.142120.0005
Override
Cache load0.00210.2815240.0001
Sytem overhead
Fetch class attribute can translate value0.00070.097520.0004
Fetch class attribute name0.00120.162540.0003
XML
Image XML parsing0.00030.034920.0001
class_abstraction
Instantiating content class attribute0.00000.001440.0000
General
dbfile0.00100.1422100.0001
String conversion0.00000.001540.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
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 5

Time used to render debug report: 0.0004 secs