We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Quote from: opengeek at Oct 26, 2012, 10:32 PM

    And the path setting is resource_static_path (and element_static_path), not static_resource_path.
    Aha! That would explain why it didn't appear to work.

    Hmm... I would presume that permissions would complicate this considerably, as resources are assigned to resource groups, which are connected to user groups to which Media Sources can be assigned.

    So if a static resource is going to be able to be tied to a Media Source, the permissions have to match up as well. Although a media source would need to be accessed before the static resource is assigned a resource group. So I would think that the permissions bit would be limited to whether or not the Media Source is group-limited, and if the user has permission to access it; any resource group settings would be irrelevant.

    That would mean that a user without the permissions to access the Media Source wouldn't be able to create the static resource using a media source; he could still create it manually however. Unless that file path field were to behave like a file upload field in the browser; the only way to populate it would be to select a file from a Media Source. I don't much like that idea.
      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
    • Today I have tried to reconfigure my modx website with the help of media source with static_resource and I met the same problems. It's really helpful when I catch on the right topic here. For conclusion I think I should add some steps to work on those at last:

      - Create a new mediasource for your public share (which is not under your modx webroot). Remember check the basePath to the absolute path of your directory: /home/username/public_share for example. Set the basePathRelative and baseUrlRelative to No

      - Create new key under Systems/Settings: resource_static_path with the absolute path you've set in the mediasource (/home/username/public_share/). Then it should work, remember to select the right mediasource to select files for static resource.

      I think I'll be handy for a little hack on static_resource which will implement information about the path of mediasource to file_path, ie: {mediasource_id:2}/path/to/file. Hope we'll get new enhancement next release. Thanks opengeek for your helpful information.
        • 3749
        • 24,544 Posts
        Good to know.

        Thanks!


        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html
          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
        • I have a question on the setting of the basePath. How does one determine the base path for a MODx Cloud installation? I get different paths from the SFTP and from the $_SERVER values in the phpinfo. Neither of these worked when set as the basePath - not relative, while the ../home/pdf/ relative path did work.
            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
          • I don't think using '..' or '.' is going to work, at least it shouldn't. That is asking for directory traversal vulnerabilities.

            The MODX_BASE_PATH should always be the same (unless you have multiple Contexts setup with separate virtual host document roots). For relativeBasePath you can use any path relative to this, but it must be within the MODX_BASE_PATH.
              • 2168
              • 9 Posts
              nepheus: Solution worked perfectly on MODx Cloud installation. Thank you so much. The "outside web root" situation had been vexing me.

              Thank you also to Jason Coward / Shaun McCormick for fixing the bug that didn't allow the creation of directories outside web root on the Cloud.

              sottwell: I was able to use the base path from the PHP Info page: _SERVER["DOCUMENT_ROOT"] (it uses some path information based on the server your Clouds are installed on).

              For NON-Cloud installations (specifically on GoDaddy for me), there was no need for nepheus' solution as all I've had to do in the Media Source setup is to use an absolute basePath (setting basePathRelative to No) and a relative baseUrl (using '..' and baseUrlRelative as Yes) for it to work with a directory that is outside web root.
              • @artifex: Yes, I noticed that we can not use the absolute path without its represent url of modx base_url. I think a plugin or custom snippet would help. I haven't tested 2.2.5 yet, I don't really know how the media source get fixes in that version (especially the file browser). I myself rarely work with media source, so it's not really a big deal right now.