We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15065
    • 138 Posts
    Hi all

    I want to arrange my folders and images files in FCKeditor MCPuck in alphabetical order.

    [ I mean when I tried to insert images to WYSIWYG editor, I click on ’Insert/Edit images’ button , then ’Insert/Edit images’ window appeared. I click on browse to select my image. Then the fckeditor window appeared. It displays all my folders and images in its create/modify order.]
    I want to get these folders in ascending (alphabetical) order.Because my images folder contains a lot of folders and images.

    I posted this issue in forum and as per the suggestions got, I add "sort($files);" at approx. line 91 in Getfolderandfiles.php located in Manager/media/browser/mcpuk/connectors/php/Commands/ and got the image files sorted.

    For sorting folders they suggest add "sort($folders);" at approx. line 60 in Getfolders.php But it doesnot work for me.

    Below is my Getfolders.php code for your Ref:
    <?php 
    class GetFolders {
     var $fckphp_config;
     var $type;
     var $cwd;
     var $actual_cwd;
     
     function GetFolders($fckphp_config,$type,$cwd) {
      $this->fckphp_config=$fckphp_config;
      $this->type=$type;
      $this->raw_cwd=$cwd;
      $this->actual_cwd=str_replace("//","/",($fckphp_config['UserFilesPath']."/$type/".$this->raw_cwd));
      $this->real_cwd=str_replace("//","/",($this->fckphp_config['basedir']."/".$this->actual_cwd));
     }
     
     function run() {
      header ("content-type: text/xml");
      echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
      ?>
    <Connector command="GetFolders" resourceType="<?php echo $this->type; ?>">
     <CurrentFolder path="<?php echo $this->raw_cwd; ?>" url="<?php echo $this->actual_cwd; ?>" />
     <Folders>
      <?php
       if ($dh=opendir($this->real_cwd)) {
        while (($filename=readdir($dh))!==false) {
         if (($filename!=".")&&($filename!="..")) {
          if (is_dir($this->real_cwd."/$filename")) {
           
           //check if$fckphp_configured not to show this folder
           $hide=false;
           for($i=0;$i<sizeof($this->fckphp_config['ResourceAreas'][$this->type]['HideFolders']);$i++) 
            $hide=(ereg($this->fckphp_config['ResourceAreas'][$this->type]['HideFolders'][$i],$filename)?true:$hide);
           
           if (!$hide) echo "<Folder name=\"$filename\" />\n";
          }
         }
        }
        closedir($dh);
       }
    -----------------------------------------------as per forum people suggested here I add 
    sort($folders);
    foreach($folders as $k=>$v) {
    	echo "<Folder name=\"$v\" />\n";
    }
    -----------------------------------------------  
    ?>
     </Folders>
    </Connector>
      <?php
     }
    }
    ?> 
     


    How can I solve this problem ? Please help me.

    Admin note: This is actually a problem with MCPuck file browser, not FCK Editor and also is present with Tiny MCE. Clarification noted above.

    thanks & regards

    Jurdy
    • So the file sorting is working for you but not the folder sorting? How would you like to see it output (folders at top, files/folders mixed together, or another way...)?
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 15065
        • 138 Posts
        Hi

        Now I got output like Folders at top ( arranged in its create/modify order ) , then files( arranged like name starting with numeric first then names starting caps( A-Z) then filenames starting with small (a-z))

        I want to get Folders at top then Files (all are arranged in ascending order ).

        thanks & regards

        jurdi



        • I’m assuming you’d want The "a"s and the "A"s all mixed together, right? (Not having caps first then lowercase...)
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 15065
            • 138 Posts
            Hi

            The main problem I am facing is that ’The folders are not arranged in alphabetical order’.In the /assets/images/ directory a lot of folders and imagefiles are there. I got only the imagefiles in alphabetical order. I want the Folders also. Now all Folders are arranged in its’ create/modify order. And if I get all ’a’ s and ’A’s together with folders at top it is better.

            thanks & regards

            jurdy
            • Alright now I understand completely. We’ll see if we put together a solution for you and include it in the 0962 update so your upgrade path will be straightforward.
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • Hi Jurdy,

                I’ve looked into this issue, and using a MODx 0.9.6.1 install, the folders and files were sorted just as you want them. What version of MODx are you using? I recommend an upgrade to MODx 0.9.6.1 if you aren’t already using it.

                If you still have problems after upgrading, can you post back with your server setup (PHP version, OS version etc.) and perhaps a screenshot of the image browser window that you’re seeing.

                Thanks,
                Garry
                  Garry Nutting
                  Senior Developer
                  MODX, LLC

                  Email: [email protected]
                  Twitter: @garryn
                  Web: modx.com
                  • 15065
                  • 138 Posts
                  Hi
                  we are using
                  MODx - 0.9.6
                  Server Software Configuration
                  Apache 2.0.54 ( UNIX )
                  PHP 4.4.7
                  Mod_SSI-2.0.54
                  Open ssi-0.9.7e
                  Mod_fastcgi-2.4.2
                  DAV-2
                  SVN-1.4.2

                  there is any alternative method other than upgrading because this site contains a lot of files and is currently using by its clients. Attached a screen shot of imagebrowser.

                  thanks

                  Jurdi
                  • Upgrading should not touch the files in use by the client, as it’s primarily the manager files and TinyMCE 2.1.2 code that is in the upgrade. The amount of work done on the 0961 upgrade fixes a ton of issues over all and really should be done. Standard caveat of backup everything first obviously applies.
                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                      • 15065
                      • 138 Posts
                      hi

                      I upgraded my modx to 0.9.6.1 . But still I got all the folders not in alphabetical order. Attached screen shots for your reference. Whether it is a problem of our server ? If you need modxlogin details for any kind of research pls send me one mail to [email protected]

                      thanks

                      jurdi