[1.6.6] Sorting file dropdown boxes

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
JasperE
New Member
New Member
Posts: 8
Joined: Tue Nov 24, 2009 9:02 pm

[1.6.6] Sorting file dropdown boxes

Post 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) )
jack4ya
Power Poster
Power Poster
Posts: 294
Joined: Thu Oct 19, 2006 10:07 am

Re: [1.6.6] Sorting file dropdown boxes

Post by jack4ya »

Still does the trick in 1.7.1  ;)
Post Reply

Return to “Tips and Tricks”