Forums / Developer / Country datatypes

Country datatypes

Author Message

Paul Forsyth

Tuesday 17 January 2006 2:00:05 am

Hi,

Would it be a good idea to consolidate the different country datatypes and produce just one which is solid and reliable?

There are now four contributed country datatypes. We have another one, which is slightly different, which i'd like to post but i dont want it to be 'yet-another-country-datatype'.

Is this worth discussing?

Paul

Bruce Morrison

Tuesday 17 January 2006 4:03:09 am

Hi Paul

I've got a couple of data types bundled into an extension that allow a database table, index and label to be defined in a content class. When editing the content object with one of these the user is presented with a dropdown of the options in the defined table. The value from the index column is stored (currently this has to be an integer).

This is extremely handy when integrating external data into eZ publish.

I've added this to pubsvn http://pubsvn.ez.no/community/trunk/extension/integrate/ - it still requires some docs, which I'll add soon.

Basically this would allow for the creation of a Country datatype by simply adding a 2 column table with an id & Country Name.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Paul Forsyth

Tuesday 17 January 2006 5:57:59 am

Our solution does use an additional db table. It is so much faster then reading the ini files. It is also ISO 3166-2 based, not '-'3' but that could just be a new db column.

Im not sure about using the integrate extension as the eZ db api isnt used. Is this deliberate?

Our db table includes the country name, 2 character code and an international dialing code. Is there any other type of data apart from the 3 character code which might be of use?

Functionally the country datatype should support:

- information collection
- serialisation
- optional class multiple selection of countries
- use within the object name
- template attribute support ( $country|attribute(show), $country.name, $country.code, $country.idc) etc.

Is there anything else a basic country datatype should have? I can think of other extras that would work well with AJAX support...

Paul

Paul Borgermans

Tuesday 17 January 2006 6:00:25 am

That's a nice one Bruce!!

Cheers, the latest round of contributions == fiesta

--paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Kristof Coomans

Tuesday 17 January 2006 6:16:18 am

Maybe two dropdown lists, one with the continents. When you select a continent, the countries of that continent show up in the second dropdown (can be an ajax-call).

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Pascal France

Tuesday 17 January 2006 6:16:34 am

Hi Paul,

I don't know if I well understand what you mean but I'm looking for a country datatype with information collection which works with eZP 3.7.2

I posted his morning about that

http://ez.no/community/forum/setup_design/country_datatype_contrib

and Lukasz replied me to have a look to:

http://ez.no/community/contribs/datatypes/ymc_country

Is the same you were talking about ?
If not, is your contry datatype available and does it works with eZP 3.7.2 ?

Regards

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Paul Forsyth

Tuesday 17 January 2006 6:33:24 am

I haven't tested it with 3.7.2 yet but there is no reason why it shouldnt.

Paul

Paul Forsyth

Tuesday 17 January 2006 6:49:15 am

So another db column could hold the continent for a country. I have a 'countries' fetch function which will fetch all countries. Normal JS could parse that for the continent fields and update using standard functions.

But I honestly think AJAX should be used whenever a round trip is necessary.

Now, AJAX for world time servers, etc....:)

Pascal France

Tuesday 17 January 2006 7:19:11 am

Hi,

Where can I download it ?

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Bruce Morrison

Tuesday 17 January 2006 4:10:24 pm

@Paul

Im not sure about using the integrate extension as the eZ db api isnt used. Is this deliberate?

What you talking about Willis? ;)

Can you show me where and I'll fix them up.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Paul Forsyth

Thursday 19 January 2006 7:12:48 am

Gosh, thats an old show that i dont see on anymore. I seem to be missing a lot of old shows on todays tv :( Im not sure what i was talking abou to be honest :)

I was thinking that for each new table in the db there should be a class extending from persistantobject with a definition inside which relates the db columns to helper functions for access. Maybe thats overkill but its a nice to have. Then you wouldnt need to use any 'selects'.

Perhaps you could follow the model of contentclass and have lots of redundant data_ elements which would be used by whatever types of data you needed?

Paul

Bruce Morrison

Thursday 19 January 2006 3:49:29 pm

Hi Paul

I was thinking that for each new table in the db there should be a class extending from persistantobject with a definition inside which relates the db columns to helper functions for access. Maybe thats overkill but its a nice to have. Then you wouldnt need to use any 'selects'.

Ahh OK, I thought tha might be what you were refering to. These datatypes came about because we have been doing quite a bit of development where we need to integrate existing databases with eZ and converting sites with databases to use eZ content objects.

Initially we were creating a custom datatypes in the manor you are talking about - with a corresponding persistantobject elements, and in some cases we still do. Now, where appropriate, we use these datatypes and find it saves quite a bit of time.

These datatypes are very handy for long lists and can be used to replace the enum/select datatypes. We have used them for nationality/country lists and I'm sure we have gotten back the time taken in development by not having to enter all that data into the content class!

Perhaps you could follow the model of contentclass and have lots of redundant data_ elements which would be used by whatever types of data you needed?

I not sure what you mean here?

One improvement I am looking at is looking at the field type of the index column and using that to determine it is gets stored in data_int or data_text - or maybe I can just store it in data_text regardless.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Paul Forsyth

Friday 20 January 2006 1:53:58 am


I not sure what you mean here?

When i said contentclass i should have said contentclass_attribute.

What i meant here was to use a single table design for each of your tables which you could copy each time you needed another table. Btw, you dont include the sql for your tables in pubsvn.

paul

Xavier Dutoit

Friday 20 January 2006 1:26:01 pm

Just to add a 5th contrib to cover the have a list of country;) :

what I do is a class country, with as many attributes as you want (name, iso code, flag...).
on the class where I need a country list, I add an enhancedobjectrelation, saying to choose the related objects as instances of the class country.

Then, populating the country list can be done as any other content and benefit from the import tools and you could easily get the list of all the (reverse) related objects to this country.

http://ez.no/community/contribs/datatypes/enhanced_objectrelation

There is more than one way to skin a cat ;)

X+

http://www.sydesy.com

Paul Forsyth

Monday 23 January 2006 1:39:54 am

Yes, thats possible Xavier :) The cost then would be to set up the countries perhaps as a package?

I'll try and post my country datatype this week. I need to get some approvals first...

As i stated at the beginning of this thread i'd like to have people work on just one country datatype and make it the best it can be. That could include a package for Xaviers approach if it were to be used?

Paul

Kristof Coomans

Monday 23 January 2006 11:12:22 pm

I like Xavier's approach.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Xavier Dutoit

Tuesday 24 January 2006 2:39:19 am

@Paul,

Yes, should be quite simple to package that, but where to put it ? Maybe see with ez if they can create a "packages" folder on the contrib ?
(What I'd really loved would be to create shared repositories for package that you can access over the net from the admin part, pear like, but I digress).

@Kristoff,

Me too ;) If you can't use the default CMS features to manage content, and a country is a content, then something is wrong somewhere.

@all,

Do you experience problem as well when trying to create big packages ? On my system, as soon as I try to export a handfull of nodes, it timeout/memory exhaust.

X+

http://www.sydesy.com

Paul Forsyth

Tuesday 24 January 2006 3:14:23 am

Until we have shared repositories/pear and so on i would just put the package into a country extension and have docs explaining how to use it. Hence the reason for this thread - for people to have one place to look.

On top of that we do need better documentation for the features we have in pubsvn. For example in the main doc area i would like to be able to discuss how to handle countries. Here we would show the different approachs available and link to datatypes and packages.

A reason i use the datatype approach is for speed. With the data as sql it is fast. However, with proper caching the object approach would work just as well. I think both methods have their merits. As you have noted the biggest issue right now is with populating the objects and creating the package!

Out of curiosity have you created country objects yet? And will the enhanced object datatype linkage with country objects allow information collection to work properly? We may need different templates to link objects correctly so that will need an extension.

Im hoping to post my datatype later today. This week for sure.

Kristof Coomans

Tuesday 24 January 2006 3:55:34 am

Populating the country objects can be accomplished easily with a command line script, partially using the information in the tables of the country datatype(s).

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Xavier Dutoit

Tuesday 24 January 2006 4:58:22 am

Hi,

I have created several countries datatypes:

One is for a directory of ngos working in the field of health. Beside listing the ngos on the country, it contains information about the life expectancy at birth, the address of the ministry of health...

Another if to collect information about human and LGBT rights in europe, with informations about the legal status of same sex relations....

I've got another client with an extranet and again some specific fields for them.

Basically, Each time it's been different in my case. I'd say that for each country, most could build upon:
country class:
-Name
-iso code (several are mentionned, I mean the one used for TLD)
-description (empty)
-flag

As for how to organise that in package (or in the whatever format to import), I'd say that it should be possible to import only part of them (for instance split that by continent).

@Kristoff:
I haven't found any easy way to batch import images into an attribute, have you ?

X+

http://www.sydesy.com