We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I am getting errors when implementing elFinder with NewsPublisher. The site is on MODX Cloud and I am having trouble figuring out what the path and URL settings should be.

    Here is what I have for the elFinderConnector snippet call:

    [[!npElFinderConnector? &browserStartPath=`/images` &browserStartURL=`/images` &browserBasePath=`/home/www/images` &browserBaseURL=`/home/www/images`]] 


    Here is the error when viewing the npElFinderConnector page:
    {"error":["errConf","errNoVolumes"],"debug":["Driver \"elFinderVolumeLocalFileSystem\" : Root folder does not exist."]}


    This is the error when trying to insert an image through the content rte field.
    Invalid backend configuration.
    Readable volumes not available.


    Additional question: are npElFinderConnector and npElFinder pages supposed to be child pages of the page that has the NP snippet?

    NP snippet call has &initfilebrowser=`1` setting.

    MODX Revolution 2.6.5-pl
    NP 3.0.4 pl


      Lucy Iannotti
      Following Sea design & development
      http://www.following-sea.com
      New Bedford, MA
      • 3749
      • 24,544 Posts
      Additional question: are npElFinderConnector and npElFinder pages supposed to be child pages of the page that has the NP snippet?
      Yes they are.

      Try adding a slash at the end of each path and URL in your snippet tag. It's a MODX convention that all paths and URLS in code end with a slash.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
      • Some progress but still not working.
        Here is my elFinder call now:
        [[!npElFinderConnector? &browserBasePath=`/paas/somenumbers/www/images/` &browserBaseURL=`/images/`]]


        If I view the elFinderConnector page in front end I see this error:
        {"error":["errUnknownCmd"]}


        If I choose the insert image button in the content rte, I am taken to the correct directory (Yay!) And I can insert the image if it is already in the directory. But I don't see an upload new image option...

        Also, more importantly for my use case, I have 5 image TVs in the form. They display as fields with buttons, but their buttons do nothing. Here is the source code in inspector for the first one:
        <div id="np-image-1-container" class="np-image">
                
                <label class="fieldlabel" for="np-image-1" title="">Cover Image 1: </label>
                <input name="image-1" class="image" id="np-image-1" type="textarea" rows="1" value="" height="30px">
                <button id="np-image-1_button" type="button">Select an image</button>
                <div id="np-image-1_preview" style="margin-top:10px;"></div>
                <script>
                $('#np-image-1_button').on('click', function() {
                    var ef_width = (("80" * 1) || 80) / 100;
                    var ef_height = (("80" * 1) || 80) / 100;
        
                    $('<div id="editor" />').dialogelfinder({
                     modal: true,
                     width: window.innerWidth * ef_width,
                     height: window.innerHeight * ef_height,
                     title: '<b>elFinder 2.0 (double-click to select your file)</b>',
                     zIndex: 99999,
        
                      /* Disable command Keyboard shortcuts, otherwise they still work
                             even if the commands are listed as disabled */
        
                      /* Disable all command shortcuts */
                      allowShortcuts: false,
        
                      /* Disable specific command shortcuts */
        
                      // commandsOptions: {
                      //     upload : {shortcuts : []},
                      //     rm : {shortcuts : []},
                      //     download : {shortcuts : []}
                      // },
        
                     url: 'http://dev.mysite.modxcloud.com/npelfinderconnector.html?media_source=2',
                     cssAutoLoad: [
                         '/assets/components/newspublisher/elfinder/elfinderthemes/osx/css/theme.css'
                     ],
        
        
                     getFileCallback: function(file) {
                       var fileUrl = file.url.replace('\\','/'); // (file is an object)
                       var mybase = file.baseUrl.replace('\\','/');
                       var finalUrl = fileUrl.replace(mybase, '');
                      
                       // This is for the preview window 
                       var imgTag = '<img src="'+ file.tmb + '">';
        
                       $('#np-image-1').val(finalUrl); // put the file path in the input field
                       $('#editor').remove(); //close the window after image is selected
                       $('#np-image-1_preview').html(imgTag);
                       // console.log("Path: " + file.path);
                       // console.log("URL: " +file.url);
                       // console.log('FINAL: '+finalUrl);
                       // console.log(file);
                     }
                  });
        
        });
        
        /* Show image preview on page load (if TV value isn't blank) */
        
            $(document).ready(function () {
                /* ToDo: Trim this */
                var val = $('#np-image-1').val();
                // console.log("Value: " + val);
                if (val.length > 0) {
                    var phpThumbUrl = '/connectors/system/phpthumb.php?';
                    var baseUrl = 'images/';
                    var imgTag = '<img src="' + phpThumbUrl + '&src=' + baseUrl + val + '&h=100&w=100">';
                    // console.log("Base URL: " + baseUrl);
                    // console.log("phpThumbUrl: " + phpThumbUrl);
                    // console.log("Image Tag: " + imgTag);
                    // console.log('Has Length');
                    $('#np-image-1_preview').html(imgTag);
                }
        
        
        
            });
          Lucy Iannotti
          Following Sea design & development
          http://www.following-sea.com
          New Bedford, MA
          • 3749
          • 24,544 Posts
          Try turning on Chrome or Firefox Dev. Tools (Ctrl-shift-i). Then load (or reload) the NP page. The console tab will tell you about JavaScript errors, the Network tab will tell you about files that aren't being found (not a 200 response).

            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
          • This is the console error when I click the "Select an Image" button on the image TV field in the NP form.

            add-resource.html:379 Uncaught TypeError: $(...).dialogelfinder is not a function
                at HTMLButtonElement.<anonymous> (add-resource.html:379)
                at HTMLButtonElement.dispatch (jquery.min.js:3)
                at HTMLButtonElement.r.handle (jquery.min.js:3)
            (anonymous)	@	add-resource.html:379
            dispatch	@	jquery.min.js:3
            r.handle	@	jquery.min.js:3


            add-resource.html being the page that has the NP snippet form.

            All files have a status of 200 except the webfont.js which is 307. (I'll disable that js and try again but I doubt it is related.)

            Also a bunch of tinymce violation warnings about touch events, etc.
              Lucy Iannotti
              Following Sea design & development
              http://www.following-sea.com
              New Bedford, MA
              • 3749
              • 24,544 Posts
              Do you have the TinyMCE Extra installed? It may be conflicting with the TinyMCE instance NP gets from CDN.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
              • There's no RTE installed in the manager at all. I recently inherited this site, and there were many MANY MANY extras installed, but not an editor. (Most extras seem to have been used in a single test page or template and then abandoned -- I am systematically uninstalling unused extras as I go.)

                I can well imagine someone getting frustrated with the TinyMCE extra and uninstalling it in a fit of peak, so I have searched through the directories for fragments of previous TinyMCE installs and don't see anything.

                But... are there other extras that you know don't play nice with NP?
                And, does the manager actually NEED a RTE for NP to work properly?
                  Lucy Iannotti
                  Following Sea design & development
                  http://www.following-sea.com
                  New Bedford, MA
                • Some more progress: I just removed all other JS and jQuery from the page that the NP form is in and now the image field pops up the elFinder browser.

                  BUT - there is no file upload button. Same with the elFinder window that opens from the RTE in content field. No way to upload a file.

                  The only buttons displayed are: Back, Forward, Open, Select Files, Get Info, Resize, Extract, Sort, About, and Full Screen

                  Is there a setting needed to make the Upload button display?
                    Lucy Iannotti
                    Following Sea design & development
                    http://www.following-sea.com
                    New Bedford, MA
                    • 3749
                    • 24,544 Posts
                    So, you don't have the Up Arrow icon at the upper left when in the image browser?
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                    • Correct. I can see about twice as many buttons when the elFinder browser is still loading files and folders, but as soon as it's finished half of the buttons disappear, including the upload.
                        Lucy Iannotti
                        Following Sea design & development
                        http://www.following-sea.com
                        New Bedford, MA