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
    1. Can a Media Source handle multiple paths?

    As an example, say I have a "designer" user that I want to have file access to my stylesheets and related images only. My main template's stylesheets and images are in assets/styles. So far, so good; I can easily create a Media Source limited to the assets/styles directory.

    The problem comes in when dealing with something like Articles. It stores its styling assets in assets/components/articles/themes. I would want my "designer" user to be able to access this directory as well.

    Would i need to provide him with two Media Sources? And would he need to select which one he wants to access? Ideally, he would be presented with two directories in the Files tab, assets/styles and assets/components/articles/themes.
      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
      • 28215
      • 4,149 Posts
      No, one path per source. Yes, you would need to setup 2 sources.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 4172
        • 5,888 Posts
        I think, skipping directories could be implemented with this line in
        modfilemediasource->getContainerList

                    
        if (in_array(trim($fileName,'/'),$skipFiles)) continue;
        if (in_array($fullPath.$fileName,$skipFiles)) continue;//this line added
        


        if we want to have placeholders like
        [[++base_path]]
        in skipFiles-list we need aditionally this line
        $skipFiles = $this->getOption('skipFiles',$properties,'.svn,.git,_notes,.DS_Store,nbproject,.idea');
        $skipFiles = $this->processPlaceholders(null,$skipFiles);//line added
        


        and something like this function in modMediaSource:
        https://github.com/modxcms/revolution/pull/238/files#diff-21

        [ed. note: Bruno17 last edited this post 14 years, 9 months ago.]
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 28215
          • 4,149 Posts
          I've added similar functionality for skipFiles to 2.2 in Git. Bruno, we're still reviewing your pull, and I'm not sure it's going a direction we want Media Sources to go. We'll get back to you on it when we can.
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
            • 4172
            • 5,888 Posts
            in 2,1.5 it was easy to manipulate the base_path for image or file - TVtypes and the path where the filemanager opens with:

            $params['basePath'] = $basePath . $scriptProperties['resource_id'] . '/';
            $inputForm = $tv->getRender($params, $value, $inputRenderPaths, 'input', $resourceId, $tv->get('type'));
            


            This is no longer possible now this way with mediaSources, since they have fix pathes as they are now. I see no chance to have for example resource-depending pathes with the filemanager without having an additional identifier for the resource, from where the filemanager was opened.

            Otherwise we would need a mediasource for each resource.

            with dynamic sources there could be pathes for resources, for parents or ultimateparents, named by TVs or by the author of a resource, that each author can have its own folder, which opens automatically.

            we only would need something like this in the mediasource-pathes for example
            [[mediasource.res_id:getauthorpath]] 


            This would make mediasources very flexible and MODXly

              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 42562
              • 1,145 Posts
              Did this ever come to pass?
                TinymceWrapper: Complete back/frontend content solution.
                Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
                • 23018
                • 353 Posts
                Quote from: donshakespeare at Jun 26, 2015, 10:00 AM
                Did this ever come to pass?

                Yes, thanks to a PR by Bruno17 you can include placeholders in your media paths:

                ```
                assets/id/[[*id]]/images/
                ```

                For more sophisticated needs, you can use a snippet.

                Have a look at Bruno17s MIGx package. It includes a snippet for dynamic media pathes.

                One warning, I found out that you can't always rely on an id based path if you are working with a dynamic media source on the frontend side.

                If you have a path like this in pdoResources or getResources it will usually claculate the path depending on the current resource id [[*id]] and not on the id of current tpl item ([[+id]]).

                Use something to replace *id with +id:

                ```
                <img src="[[+thumb:replace=`[[*id]]==[[+id]]`]]" />
                ```

                Cheers,

                pepebe [ed. note: pepebe last edited this post 11 years, 3 months ago.]
                  Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe