We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36695
    • 47 Posts
    In a CMP I have a window that opens with the following item as one of its fields:
    ,{
                        xtype: 'modx-combo-browser'
                        ,browserEl: 'modx-browser'
                        ,fieldLabel: 'Photo/logo'
                        ,name: 'photosource'
                        ,hideFiles: true
                        ,openTo: config.record.openTo || ''
                        ,id: 'photosource-file'
                        ,anchor: '90%'
                        ,maxLength: 255
                        ,value: config.record.photosource || ''
    
                    }
    


    The window is called from a handler in the getMenu method of a grid. The handler makes an ajax request which, on success, shows the window and uses setValues to fill in some data (including the config.record.photosource seen in the code above). The value shown in the combo-browser is correct.
    When I click the input however, the browser does not open in the correct directory. I have two questions:

    1. in the openTo property of the item in the code above, what is the format of the data required? Is this a path or url? Relative or absolute? And will this make the browser open in the right folder?
    2. How do I make the browser open in a particular media source (even if I have to hard code this)?
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Isn't it just the "source" config option with the ID of the media source?
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 36695
        • 47 Posts
        I'm suitably chagrined. The "source" config does indeed work. I'm almost 100.1% sure I tried this before, but obviously I was still seeing the effects of some other misconfiguration.
        It hasn't solved my issue of windows opening with the same value set in them as the row where the first window opened, but I guess that's a whole other thing for me to play around with.

        Thank you.
          • 17403 ☆ A M B ☆
          • 183 Posts
                  {
                      xtype: 'modx-combo-browser'
                      ,browserEl: 'modx-browser'
                      ,source: config.source || MODx.config.default_media_source
                  }


          Set browserEl value to avoid conflict with others windows.
            zaenal.lokamaya
            • 17403 ☆ A M B ☆
            • 183 Posts
            We also could call MODx.browser using a button, without MODx.combo.Browser. Same as what we saw in TinyCME editor on browse images.

            {
                xtype: 'container'
                ,border: true
                ,anchor: '100%'
                ,layout: 'form'
                ,items:[{
                    xtype: 'button'
                    ,id: 'product-image-button'
                    ,cls: 'x-btn-text bmenu' //'x-btn-icon bmenu' : 
                    ,style: 'float:right;'
                    ,disabled: false
                    ,text: "Browse Image"
                    ,listeners: {
                        'click':{
                            fn: function(btn) {
                                if (Ext.isEmpty(this.browser)) {
                                    this.browser = MODx.load({
                                        xtype: 'modx-browser'
                                        ,returnEl: null
                                        ,id: 'product-image-browser'
                                        ,multiple: false
                                        ,config: MODx.config
                                        ,source: MODx.config.default_media_source || MODx.source
                                        ,allowedFileTypes: 'gif,jpg,jpeg,png'
                                        ,listeners: {
                                            'select': {fn: function(data) {
                                                //MODx.fireResourceFormChange();
                                                alert(Ext.encode(data));
                                            },scope:this}
                                        }
                                    });
                                }
                                this.browser.show(btn);
                                return true;
                            }
                            ,scope:this
                        }
                    }
                }]
            }
            
            [ed. note: lokamaya last edited this post 13 years, 10 months ago.]
              zaenal.lokamaya