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

Announcement

Symphony's issue tracker has been moved to Github.

Issues are displayed here for reference only and cannot be created or edited.

Browse

Closed#222: Sort order of dynamic options in select boxes

When dynamically populating select boxes with values of other sections these are sorted in a strange way (see attachment). I would expect two things:

  1. an ascending order (currently it’s descending)
  2. a natural sort order (1, 2, 3 … 9, 10, 11, 12 …)
Attachments:
sym_sortorder.png

I agree with the ordering, it would make more sense for ascending.

I’m not sure how a “natural” sort order can be achieved, since the values are stored as plain text. As such, the sort is alphabetical, hence you see the order 1, 10, 11, 2, 3 ... since the field needs to store both alphabetical and numerical data.

If you need to govern the order of these, you could use a Select Box Link which honours the ordering of the related section (which could be sorted manually with the Order Entries extension).

I’m not sure how a “natural” sort order can be achieved, since the values are stored as plain text.

Shouldn’t it be possible to populate an array with these values before populating the select box and applying natsort() to that array?

Actually it’s quite easy to fix. Replace line 103 of field.select.php

$states = $this->getToggleStates();

with

$states = $this->getToggleStates();
natsort($states);

This will sort the options naturally ascending.

I had no idea the natsort() function existed. Awesome :-)

Looks like this made it into 2.0.7.

This issue is closed.

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