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.