We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17855
    • 43 Posts
    Hi

    Simple stuff I am sure, I am using a TV to hold an image. easy.

    But I also need the URL for the image. Having searched for a solution, Ryan Thrash reccomends using another TV and @EVAL binding to get the URL and simply calling a second TV when you need just the url and not <img src...etc.

    But being new I dont know how to form the @EVAL binding

    I am guessing it’s something like @EVAL return ([*imageTV*]) but cant quite get it to work.

    Any help appreciated - thanks all
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You’ll need to use the API function getTemplateVarOutput() for that.
      http://wiki.modxcms.com/index.php/API:getTemplateVarOutput
        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
        • 17855
        • 43 Posts
        Thanks - but if I have the image widget wont that mean the output of the tv is <img etc on not the url?

        just trying to play with it now :-

        @EVAL getTemplateVarOutput(’projectImage’)
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          There are other TV API functions, one of them should just return the content of the TV rather than its output.
            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
            • 17855
            • 43 Posts
            thanks found getTemplateVar etc

            still working on the syntax though...thats my biggest problem..

            thanks for the help ;-)
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Yeah, I didn’t give you any examples because I’m always stumbling through those by trial-and-error, then never think to actually make a record of what I did!
                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
                • 17855
                • 43 Posts
                I know the feeling! best -
                  • 17855
                  • 43 Posts
                  ok I have got his far, I am using the following @EVAL on a tv called projectImageURL

                  @EVAL $tv ="projectImageMap";$id = isset( $id )? $id: $modx->documentIdentifier;$tvValue = $modx -> getTemplateVar($tv,"*",$id);return print_r ($tvValue);


                  in the default value field of the tv.

                  But the document Identifer is being evaluated from the page on which I am calling ditto. How do I get the tv that the @EVAL is "filling in" (projectImageURL) to always reference the original doc itself - if you understand. SO that all

                  projectImageURLs come from projectImageMap on each doc?

                  Also from the array do I extract the image name:-

                  $imageName = $tvValue["value"]


                  ? thanks