We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3186 ☆ A M B ☆
    • 279 Posts
    Hi all,

    I have made a plugin 'OnDocFormSave' which saves necessary field values into a custom table to make filtering and searching a lot faster (where I have 500+ resources). I do also use this "index" table to generate my overview pages and for each entry there is also an image needed. So I have added a "image" field to my custom table and want it to be filled with the image path, of course...

    Here is what I do in my plugin;

    $imageTV = $modx->getObject('modTemplateVar', 10); // for me ID 10 is image TV
    $imagePath = $imageTV->renderOutput($resource->get('id'));


    The TV is binded to a media source which haves a relative path like "assets/uploads/images/". The value stored in $imagePath of above is the path relative to the media source path. But I want to include that path and thought renderOutput() will achieve this.. As "getResources" also uses this method when &processTVs=`1` is provided.

    Can anyone get my point and help me a little further with this? Thanks in advance!

    Regards, Bert
      MODX Ambassador (NL) & Professional MODX developer
      Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
      MODX e-commerce solution SimpleCart
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Hm. I would use a MIGxDB TV instead. It takes care of all these details for you. http://rtfm.modx.com/display/ADDON/MIGXdb

      The "renderOutput()" function will only render an output widget, for example if your image TV uses an image output widget it will render the full HTML image tags.

      For what you are doing, you probably will have to access the media source values. I don't find any documentation on how to do that, but I'm sure there's a mediasource object that you can get. The API documentation mentions a "getBaseURL()" function for the modmediasource class.
        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
        • 3186 ☆ A M B ☆
        • 279 Posts
        Susan, thanks for your reply...
        But you cannot use MIGX for my goal I think.. because I want a own table to search in; I save the resources fields needed and also for a single record I save my TV values, large amount of TV values will be saved in one single record, will make it easier to filter results
          MODX Ambassador (NL) & Professional MODX developer
          Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
          MODX e-commerce solution SimpleCart
          • 3186 ☆ A M B ☆
          • 279 Posts
          I do now have used getBaseUrl() method indeed to get the path before the path saved as TV value. But why is getResources not using that? or do I miss something?
            MODX Ambassador (NL) & Professional MODX developer
            Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
            MODX e-commerce solution SimpleCart
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            That's what MIGxDB is for... custom tables.
              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
              • 3186 ☆ A M B ☆
              • 279 Posts
              I mean database tables he, not a HTML table ;-)
              I do not know MIGX that very well, but I realy think MIGX cannot do what I do, because it's to custom
                MODX Ambassador (NL) & Professional MODX developer
                Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
                MODX e-commerce solution SimpleCart
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Custom database tables... hence the name "MIGxDB" for MultiGrid extension DataBase.

                Check out the documentation. I think you'll find it will do exactly what you have in mind.
                  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