freaking1 / wordpress-custom-content-type-manager

Automatically exported from code.google.com/p/wordpress-custom-content-type-manager
0 stars 0 forks source link

Ordering the list alphabetically in Directory field type #504

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Although it is not necessarily a bug, it's a nice-to-have feature specially 
when there are a lot of files and folders in the source directory being listed;

To re-produce;

1- Create a "Directory" custom field
2- Set the source directory to a folder with hundreds of files and folders
3- Check "Traverse Directories"
4- Add it to a custom post type and save
5- add new/edit a post of the type you just added the field to

Now when the dropdown list is generated it's not sorted alphabetically and 
depending on the number of files it's difficult to find files.

Solution;

The real solution would most probably need an extension to the Iterator class 
but since the CCTM plugin is storing the list of files in an array and creates 
the dropdown list from it we can just sort the array in between.

I fixed the problem by adding the following to line 147 in 
"fields/directory.php"

sort($options,SORT_STRING);

(Just before "$this->options = $options;")

*SYSTEM INFO* 
------------------------ 
Plugin Version: 0.9.7.6-pl
WordPress Version: 3.5.1
PHP Version: 5.2.17
MySQL Version: 5.1.53-log
Server OS: Linux

Original issue reported on code.google.com by soro...@thedevguys.com on 12 Jun 2013 at 4:55

GoogleCodeExporter commented 9 years ago
Thanks.  Fix added.

Committed revision 725836.

Original comment by ever...@fireproofsocks.com on 12 Jun 2013 at 6:29