We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I am having trouble using the [[migxResourceMediaPath]] snippet from the "Use resource-specific mediasource and multifile-uploader" tutorial (http://rtfm.modx.com/display/ADDON/MIGX.Use+resource-specific+mediasource+and+multifile-uploader) to assign resource-specific paths to a standard image TV.

    When I attempt to do so, the image is not loaded in the front end properly when passed through phpThumbOf in a getResources call. phpThumbOf doesn't even seem to be processing the file at all, the URL is there to the original resource, but it's not accessible to the browser. Does anyone know how to remedy this? The Media Source works fine for file uploads in MIGX, just not for this TV.

    Does anyone have an idea of what is wrong? I LOVE having resource specific Media Sources, it simplifies things for users to a huge extent and I would love to have this extended to other TV's.

    Here is how I have it setup:

    [[getResources?
    &parents=`[[*id]]`
    &tpl=`sectionListTpl`
    &depth=`1`
    &showHidden=`1`
    &includeTVs=`1`
    &processTVs=`1`
    ]]


    sectionListTpl:
    <li><a href="[[~[[+id]]]]"><img src="[[+tv.pageIcon:phpthumbof=`w=50&h=50`]]" />[[+pagetitle]]</a></li>

    This question has been answered by Bruno17. See the first response.

      Ben Morrison
      Hacking templates to pieces since 2003
      • 4172
      • 5,888 Posts
      if the filepath is not generated correctly,
      try not to process the image-TV and add the resource-specific-path to the output by yourself.
      You will then need a custom-output-filter, something like

      [[+tv.pageIcon:addbefore=`path/[[+id]]/`:phpthumbof=`w=50&h=50`]]


      to get it work together with phpthumbof

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

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • I stopped the processing of the TV and removed phpThumbOf (the latter just to see what I get) but oddly enough it is generating the URL based on the parent resource of the resource the TV is assigned to. So the path ends up being:

        /assets/resourceimages/31/stw-mc2stem-overview-og.jpg

        Rather than the proper output of:

        /assets/resourceimages/32/stw-mc2stem-overview-og.jpg

        With 31 being the parent of 32. So adding the file path prior to the output doesn't work. I didn't notice that this was the issue before and why it wasn't working. Is there a way to modify the migxResourceMediaPath snippet to fix this? I don't know much of any PHP.
        [ed. note: maroonlover last edited this post 10 years, 11 months ago.]
          Ben Morrison
          Hacking templates to pieces since 2003
          • 4172
          • 5,888 Posts
          did you also try
          &prepareTVs=`0`
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
          • Ah that did remove the path allowing me to add the proper path onto it manually. I don't know how to write a custom output filter so I set it up like:

            <li><a href="[[~[[+id]]]]"><img src="assets/resourceimages/[[+id]]/[[+tv.pageIcon:phpthumbof=`w=20&h=20`]]" />[[+pagetitle]]</a></li>


            But, like expected, phpThumbOf doesn't work that way. I hate to ask (god knows you do enough work with MIGX, thanks by the way) but I'm a php dunce, could you show me the code I would need for the output filter "addbefore" ?
              Ben Morrison
              Hacking templates to pieces since 2003
            • discuss.answer
              • 4172
              • 5,888 Posts
              snippet-code for add_before:

              return $options.$input;
              


              usage:
              [[+tv.pageIcon:add_before=`assets/resourceimages/[[+id]]/`:phpthumbof=`w=20&h=20`]]


              does this work?
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
              • YES! Thank you!
                  Ben Morrison
                  Hacking templates to pieces since 2003
                • Hey continuing the topic into a different question...

                  I modified the snippet to create a resource specific directory BUT to set the Media Resource path to the folder containing those directories. This means folders are still created to organize resource-specific files automatically, but that from TinyMCE (content area) the user can also access other folders for site-wide content such as documents, where you don't want to have to upload revisions multiple times. Works like a charm and simplifies things for my users giving a place for everything.

                  My only issue is that I really don't want that done for those resources of certain templates but instead to direct them to another directory. IE: images related to articles (articles plugin, can't hide content area and replace with TV) are stored elsewhere from general site content.

                  A more fully fledged snippet I guess would take JSON strings so that multiple templates (comma delineated list) can be directed to multiple directories, creating a fully configurable default Meda Source for the content section of resources. Like so:

                  {"templatenumbers":"directory_to_redirect_to":"directory_to_create"},
                  {"3,7,8":"assets/article_content/":"assets/article_content/{id}"}


                  If Articles worked with form customization this would be pointless, but as of now it does not.

                  Now I KNOW that is a lot more work in PHP and way out of my league but I would appreciate any help you could give me.
                    Ben Morrison
                    Hacking templates to pieces since 2003
                    • 40590
                    • 9 Posts
                    Bruno,
                    I'm having the same issue that Ben described (ie, my image TVs gets processed, but the path is for the parent ID instead of the resource ID). Except, instead of using a getResources call like Ben, I'm using Articles to aggregate blog articles. So there is no '&prepareTVs' property (that I'm aware of) that would allow me to remove the path so that I can specify it manually with the help of the 'add_before' snippet. Any insight into how I could overcome this issue in my scenario?

                    What's also strange is that everything was working fine for a while. All of the sudden today the images stopped rendering in the front-end. The only thing that I can think that I changed was the "Articles URL Format" for those child resources. I just don't see how that might have affected the image TV's.