Page 1 of 1

[1.6.6] Sorting file dropdown boxes

Posted: Mon Nov 30, 2009 8:17 pm
by JasperE
Here's a slight modification to sort image selection dropdown boxes in the admin control panel. Quite useful for those  {content_image} tags.
Just add the bold line, that's all.


File: lib/page.functions.php
------------------------------------------------------------------------
function create_file_dropdown($name,$dir,$value,$allowed_extensions,$optprefix='',$allownone=false,$extratext='',
                             $fileprefix='',$excludefiles=1)
{
 $files = array();
 $files = get_matching_files($dir,$allowed_extensions,true,true,$fileprefix,$excludefiles);
 if( $files === false ) return false;
 $out = "\n";
 if( $allownone )
   {
     $txt = '';
     if( empty($value) )
       {
         $txt = 'selected="selected"';
       }
     $out .= "  --- ".lang('none')." ---\n";
   }

 sort($files);
 foreach( $files as $file )
   {
     $txt = '';
     $opt = $file;
     if( !empty($optprefix) )

Re: [1.6.6] Sorting file dropdown boxes

Posted: Mon Jul 05, 2010 9:26 am
by jack4ya
Still does the trick in 1.7.1  ;)