We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33968
    • 863 Posts
    I’m trying to configure a modx-combo-browser window to open in the exact folder for the selected object, rather than having the user navigate through folders to find it. Got that working fine.

    Only problem is, how do I then save the full path to the selected image (saved to the data property), rather than the relative path from the start directory? I’ve been playing with different basePath/baseUrl/relativePath/relativeUrl combinations but can’t get the full path.

    Eg.
    - image is located at /assets/images/category/item/image.jpg
    - basePath is /assets/images/category/item/
    - BUT image path saved is then only ’image.jpg’ which causes obvious problems when I try to get that image elsewhere.

    Any ideas?

      • 4172
      • 5,888 Posts
      Don’t know your situation, but can’t you add your basePath to your image-filename just before saving?
      Or store the path anywhere and put them together before frontend-output, as its done with image-TVs?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 33968
        • 863 Posts
        Thanks for the response Bruno - I’ve found a way to prefix the path both on ’select’ so I can load the image in my panel as soon as selected, and then in my save processor.

        Really I was just wondering if it’s possible to configure with the right combination of those baseUrl, etc settings
          • 36926
          • 701 Posts
          Hey Lucas,

          Firstly, how did you manage to get the correct folder to open for a particular object and secondly how did you solve the path issue.

          I realise i can edit the input options for the individual TV, but i'm actually being lazy and wondered if there's a quick way to do it for all image TVs.

          Thanks

          Ben
          [ed. note: bennyb last edited this post 12 years, 5 months ago.]
            • 33968
            • 863 Posts
            Hi Ben, this was not for an image TV but for a CMP field and I was setting the paths in the raw js code. I don't really use TVs very much but can you not set a path as a default for your image tv?
              • 36834
              • 25 Posts
              I'm not sure if this is what you mean BUT look in 'manager/assets/modext/core/modx.view.js'. The MODx browser window has an 'openTo' config setting that controls which directory the browser tree/view expand/open to when launched.

              You can add the 'openTo' setting to the modx-combo-browser object

              {
                          xtype: 'modx-combo-browser'
                          ,fieldLabel: _('pm.item')
                          ,name: 'url'
                          ,id: 'pm-'+Ext.id()+'-url'
                          ,allowBlank: false
                          ,openTo: 'assets/resources/images/'
                          ,hideFiles: true
                          //,width: 300
                      }


              or extend/override the orignal objects - don't imagine it would take much to pass a value from an event.

              MODx.combo.Browser = function(config) {
                  config = config || {};
                  Ext.applyIf(config,{
                     width: 300
                     ,triggerAction: 'all'
                  });
                  MODx.combo.Browser.superclass.constructor.call(this,config);
                  this.config = config;
              };
              
              Ext.extend(MODx.combo.Browser,Ext.form.TriggerField,{
                  browser: null
                  
                  ,onTriggerClick : function(btn){
                      if (this.disabled){
                          return false;
                      }
                      
                      if (this.browser === null) {
                          this.browser = MODx.load({
                              xtype: 'modx-browser'
                              ,id: Ext.id()
                              ,multiple: true
                              ,prependPath: this.config.prependPath || null
                              ,prependUrl: this.config.prependUrl || null
                              ,basePath: this.config.basePath || ''
                              ,basePathRelative: this.config.basePathRelative || null
                              ,baseUrl: this.config.baseUrl || ''
                              ,baseUrlRelative: this.config.baseUrlRelative || null
                              ,hideFiles: this.config.hideFiles || false
                              ,rootVisible: this.config.rootVisible || false
                              ,allowedFileTypes: this.config.allowedFileTypes || ''
                              ,wctx: this.config.wctx || 'web'
                              ,openTo: this.config.openTo || 'assets/resources/images/'
                              ,listeners: {
                                  'select': {fn: function(data) {
                                      this.setValue(data.relativeUrl);
                                      this.fireEvent('select',data);
                                  },scope:this}
                              }
                          });
                      }
                      this.browser.show(btn);
                      return true;
                  }
                  
                  ,onDestroy: function(){
                      MODx.combo.Browser.superclass.onDestroy.call(this);
                  }
              });
              Ext.reg('modx-combo-browser',MODx.combo.Browser);


              [ed. note: simonp98 last edited this post 12 years, 5 months ago.]
                • 36926
                • 701 Posts
                Hey guys thanks for the replies, I thought i'd subscribe to this thread but doesn't look like it did which is why i'd not responded sooner.

                @lucas, yeah you can set the path for individual TVs but ideally i want all image TV to go to the image folder, all file TVs to go to the file folder and so on. LIke the EVO days. It does seem that 2.2 may change this and give me more control over the default setting, but not had a proper play.

                @simonp98 thanks for that look like that could be a work around, but do feel it should be something easily set within the manager. But as mentioned above looks like 2.2 may address this issue.

                Thanks again for the responses

                B