We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    This is great!

    Although from the actual code modification point of view, getting it in the database would be much easier than getting it out. It only involves adding it to the save resource functionality. There are a lot of "front-end-client" functions in MODx. makeURL() comes to mind. I'm not (yet) familiar enough with Revo's guts to have any idea of what else might need to be modified.
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 17403 ☆ A M B ☆
      • 183 Posts
      Got it.

      MODx.combo.Browser is returning Object data, not only a single filepath or filename.

      Using Ext.encode() or Ext.util.JSON.encode(), we get the JSON string. Add another hidden field to resource panel to store this value, then save it to resource::properties when we send back the data to server.

      There are no MediaSourceID object, but "relativeUrl" and "fullRelativeUrl" is sufficient.

      If we really need MediaSourceID, we can get it by parsing "image" or "thumb" url. At the end of both url, we find source=1 as MediaSourceID.

      {
          "name":"favicon.png"
          ,"cls":"icon-png"
          ,"url":"images/favicon.png"
          ,"relativeUrl":"images/favicon.png"
          ,"fullRelativeUrl":"/images/favicon.png"
          ,"image":"/connectors/system/phpthumb.php?src=images/favicon.png&w=114&h=114&HTTP_MODAUTH=***SECRET***&f=png&q=90&wctx=mgr&source=1"
          ,"image_width":114
          ,"image_height":114
          ,"thumb":"/connectors/system/phpthumb.php?src=images/favicon.png&w=80&h=60&f=png&q=90&HTTP_MODAUTH=***SECRET***&wctx=mgr&source=1"
          ,"thumb_width":80
          ,"thumb_height":60
          ,"pathname":"PATH_TO_FILE/images/favicon.png"
          ,"ext":"png"
          ,"disabled":false
          ,"size":9035
          ,"lastmod":"2012-11-08T11:41:11"
          ,"menu":[{"text":"Delete File", "handler":"this.removeFile"}]
          ,"shortName":"favicon.png"
          ,"sizeString":"8.8 KB"
          ,"dateString":"11/08/2012 11:41 am"
      }
      [ed. note: lokamaya last edited this post 13 years, 9 months ago.]
        zaenal.lokamaya
        • 17403 ☆ A M B ☆
        • 183 Posts
        Just a note: there is a bug on manager/assets/modext/core/modx.view.js (MODx version 2.2.5 pl)

        Close the windows browser without selecting any files, returning javascript error: "m.apply is not a function". This is because button "Close" use default ExtJS hide Event property, that will bubbling and search for beforeHide and afterHide function.

        //modx.view.js line 241-251
                ,buttons: [{
                    id: this.ident+'-ok-btn'
                    ,text: _('ok')
                    ,handler: this.onSelect
                    ,scope: this
                },{
                    id: this.ident+'-cancel-btn'
                    ,text: _('cancel')
                    ,handler: this.hide
                    ,scope: this
                }]
        



        BUG FIX
        //.........................
        //change handler for "Close" button
        //.........................
                },{
                    id: this.ident+'-cancel-btn'
                    ,text: _('cancel')
                    ,handler: this.onClose
                    ,scope: this
                }]
        //.........................
        //add this line of code at 342, just before onSelect
        //.........................
            ,onClose: function() {
                this.hide();
            }
        


        [ed. note: lokamaya last edited this post 13 years, 9 months ago.]
          zaenal.lokamaya
          • 37693
          • 47 Posts
          Hi

          To clarify, is this to do with not being able to set up a Media Source and use that in a Static Resource?

          For example I have set up the default media source to be '/assets/media/', but when I select a file from the Static Resource it still always takes me to the site root in the file browser.

          Obviously this isn't ideal to hand this to clients as it gives them access to the whole site (+ increases the chance they'll add assets all over the place).

          Many thanks,
          Shaun
            • 20215
            • 144 Posts
            Hi
            has anyone found a workable solution?
              ----------------------------------
              canale irc Italiano #modx server: tophost.azzurra.org
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              There is one way.

              Create the media source, and limit your editor users to that media source.

              For the path, put the full path to the file directory, and say it's not relative. Leave the URL empty.

              Create a chunk and put the same full path to the directory in it. If you ever move the files, you'll just need to edit the path in the media source and the chunk.

              There are two ways to handle the next part. Either the user needs to prepend the chunk tags to the path in the static resource, or you can create a plugin using the onBeforeDocFormSave to automatically prepend the chunk tags if the resource being saved is a static resource (or whatever check you need to make to be sure to only do this with your file media sources).

              This only works for files stored within the local file system. If you want to serve files from an external repository, you'll need a different solution.

                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 20215
                • 144 Posts
                I'll try as soon as possible.

                Thank you for your assistance.
                Bye!
                  ----------------------------------
                  canale irc Italiano #modx server: tophost.azzurra.org
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  The other way is to do some more leaning on the MODX team to get static resources to work properly with Media Sources!

                  For what it's worth, thinking that they would work as TVs and static elements do is the main reason why I switched to working with Revo a couple of years ago. I'm working at it, but I'm still not at the point where I can fix this myself.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org