3 users online. Create an account or sign in to join them.Users

Search

For some reason I thought there was an extension that populated a select box with a list of countries for a form. I can’t find it.

Then I though perhaps it’s not really needed.

I would just need to create a DS with all the countries and dynamically select it.

Any thoughts?

Ok, I imported an XML source into a Dynamic XML.

I then tried to create a Select field and pull in the information, but it didn’t show the DS in the drop down menu.

Is there a reason for this?

A clever way to achieve this would be to write the countries as XML. The ISO provide a list as XML already. You should be able to include this into your /workspace and load it into your page/utility XSL file using document(path/to/xml/countries.xml) and use it to create a select box.

Sorry Nick,

Not sure I fully understand you there.

Creating the XML is not a problem.

But you saying I should create a utility xml file?

And create a select box manually and not use the Section editor?

I then tried to create a Select field and pull in the information, but it didn’t show the DS in the drop down menu.

As far as I know you cannot populate a Select Box field with the contents of a Dynamic Data Source. The reason being that the Data Source can return the XML in any format it likes, so the Select Box won’t know how to interpret this or know which XML elements to use as the option values.

My method above will solve the problem for front-end forms and events, since it can create an HTML <select>...</select> populated with countries. You could use your Dynamic XML DS to do this too (instead of my document() idea).

However if you want the list to be present as a Select Box field in the backend also, you will need to do one of three things:

  • paste comma-separated list of countries into the Select Box static values (although not sure whether this has a character limit)
  • create a section named Countries with an entry for each Country and use this as the dynamic contents of the Select Box. Bauhouse has done this in one of his old ensembles. If you use this method you may be better off choosing a Select Box Link to relate the two sections together more robustly
  • write a custom field “Country Select field” which provides the functionality you’re after (perhaps reading these values from an XML file). This could be abstracted out into a generic field that can be used for any purpose, which reads in XML for its values

Thanks Nick, I think I need to start building up a bunch of DS’s like this. This kind of thing would be useful in future projects.

I couldn’t find the Ensemble with it on, so I made a drink and manually created the section and DS. I now have a DS with all my countries in. Is there any way I can port this? Other than creating an Ensemble, but I think it would be useful to be able to plug this into my projects in the future.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details