Forums / Developer / New datatypes: select and combo boxes that get options from seperate table

New datatypes: select and combo boxes that get options from seperate table

Author Message

Hardy Pottinger

Tuesday 27 July 2004 11:53:26 am

My goal is to produce two new datatypes which will provide a user with a combo box (i.e. a select list as well as a text field for new entries, and yes, I know this will be using javascript), as well as a list box, that store possible options in a seperate table. We want to do this to facilitate easy manipulation of the option values, and possibly even integrate the option table with an external database (though that certainly doesn't have to happen now... but we could go that way pretty easily, if we do it this way).

My thinking is that I can use very similar code for both datatypes. I will be storing the final string value in the normal content object way, so we're looking at building both of these datatypes off of the string datatype. In both datatypes, we're really only talking about tweaks to the content edit templates, and the validation/storage functions.

Anyway, I'm posting this message to see if a) anyone's already done something similar and/or b) this sounds like I'm barking up the right tree and/or c) this sounds like I'm barking mad! :-)

Thanks for any help you can provide.

Paul Forsyth

Wednesday 28 July 2004 12:55:44 am

So, your two new datatypes are actually quite similar. Could both be implemented with the same datatype code but with a different template to render it? Your description sounds similar to the current datatype ezselection. Apart from using a separate table how does it differ?

paul

--
http://www.visionwt.com

Hardy Pottinger

Wednesday 28 July 2004 7:18:26 am

You're correct, they are too similar, and I'll only be coding one datatype. It *is* very similar to the selection datatype, but my goal is to come up with a combo box--a term which is often used to mean select box, but really means a *combination* between a select box and a text field. There's no such thing in HTML's specs, but you can code something very similar by presenting a select box and a text field, and tying together their behavior with javascript (and server-side scripting, as a backup, in case the client browser does not provide javascript capabilities). Here's a good write-up of how the HTML code will work: http://www.cs.tut.fi/~jkorpela/forms/combo.html.

I'm still planning to start with the string datatype, because it will make accessing the data simpler (and will also facilitate importing of legacy data). But I'll be borrowing code from the selection datatype (in particular, the classAttributeContent function).

I really like the idea of using just one datatype for this, because it will give us some freedom with the interface. If suddenly our client declares "No, I don't want the users to be able to enter their own data, they're crazy and are making too many duplicates!" We'll be able to just uncheck a box in the class, and the combo box will revert to a select box.

As long as we're talking about datatypes, we had a need to code up some strings fields with various simple validation rules. Instead of making individual datatypes for this, since the rules were simple enough to code into a single regexp per field, I came up with a datatype that lets you define the regexp validation as part of the class attribute definition in the admin interface. As soon as I'm sure that's working as intended, I'll contribute it to the community.

Paul Forsyth

Wednesday 28 July 2004 7:31:50 am

I know what you are referring to. I've used too many widget toolkits in my time :) Sounds very nice.

Have a good look at the way ezselection works from the db point of view. The main reason for a new datatype is to facilitate the extra storage required by the data. Once you create another class that links in to the datatype content you can pretty much link any other db table to it.

paul

--
http://www.visionwt.com

eZ debug

Timing: Jan 18 2025 19:10:14
Script start
Timing: Jan 18 2025 19:10:14
Module start 'content'
Timing: Jan 18 2025 19:10:14
Module end 'content'
Timing: Jan 18 2025 19:10:14
Script end

Main resources:

Total runtime0.8063 sec
Peak memory usage4,096.0000 KB
Database Queries197

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.0938180.7813
Module start 'content' 0.00560.6839 768.8750526.9766
Module end 'content' 0.68960.1167 1,295.8516336.7109
Script end 0.8062  1,632.5625 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00430.5305210.0002
Check MTime0.00150.1905210.0001
Mysql Total
Database connection0.00070.088910.0007
Mysqli_queries0.739191.66241970.0038
Looping result0.00170.21121950.0000
Template Total0.778696.620.3893
Template load0.00210.258220.0010
Template processing0.776596.307320.3883
Template load and register function0.00020.020210.0002
states
state_id_array0.00140.170310.0014
state_identifier_array0.00120.144220.0006
Override
Cache load0.00180.2191250.0001
Sytem overhead
Fetch class attribute can translate value0.00160.199730.0005
Fetch class attribute name0.00090.114650.0002
XML
Image XML parsing0.00080.100130.0003
class_abstraction
Instantiating content class attribute0.00000.001260.0000
General
dbfile0.00460.5662270.0002
String conversion0.00000.000630.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
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs