Forums / Setup & design / Selection attribute, how to handle changes in options

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

eZ debug

Timing: Jan 18 2025 04:15:55
Script start
Timing: Jan 18 2025 04:15:55
Module start 'content'
Timing: Jan 18 2025 04:15:55
Module end 'content'
Timing: Jan 18 2025 04:15:55
Script end

Main resources:

Total runtime0.2044 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0088 589.0703180.8125
Module start 'content' 0.00890.0061 769.882893.8359
Module end 'content' 0.01490.1894 863.7188522.3750
Script end 0.2043  1,386.0938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00432.1135200.0002
Check MTime0.00200.9584200.0001
Mysql Total
Database connection0.00140.681010.0014
Mysqli_queries0.151774.20341410.0011
Looping result0.00140.68181390.0000
Template Total0.189092.510.1890
Template load0.00130.638510.0013
Template processing0.187791.832610.1877
Override
Cache load0.00070.360110.0007
Sytem overhead
Fetch class attribute can translate value0.00200.958510.0020
XML
Image XML parsing0.00030.145310.0003
General
dbfile0.00231.1197200.0001
String conversion0.00000.002630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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