We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7155
    • 160 Posts
    How do I assign a file like (like jpeg,pdf,zip..etc) to a TV through a Snippet?
      • 15469
      • 64 Posts
      Make your snippet return what you like and bind it to a TV...
      @EVAL $modx->runSnippet("Ditto", array("tpl" => "<post><title>[+title+]</title><summary>[+summary+]</summary></post>"));
      This would bind the output of Ditto to a TV.
        $cd /pub
        $more beer
        • 7155
        • 160 Posts
        Quote from: Katzenfutter at Apr 17, 2009, 06:09 AM

        Make your snippet return what you like and bind it to a TV...
        @EVAL $modx->runSnippet("Ditto", array("tpl" => "<post><title>[+title+]</title><summary>[+summary+]</summary></post>"));
        This would bind the output of Ditto to a TV.

        Thank you for responding

        In this case which is the TV or where is the TV is it the array?
          • 15469
          • 64 Posts
          That @eval needs to be assigned to your TV, so this TV "carries" the output oft Ditto in this case.
          Imagine your snippet in Dittos place for example:

          Your snippet would produce any kind of data. The TV with the @eval is bound to any template you like and is now responsible to represent the ouput of your snippet.

          Hope, i got it right and you get ME right wink

          Cheers
            $cd /pub
            $more beer
            • 7155
            • 160 Posts
            Quote from: Katzenfutter at Apr 17, 2009, 08:34 AM

            That @eval needs to be assigned to your TV, so this TV "carries" the output oft Ditto in this case.
            Imagine your snippet in Dittos place for example:

            Your snippet would produce any kind of data. The TV with the @eval is bound to any template you like and is now responsible to represent the ouput of your snippet.

            Hope, i got it right and you get ME right wink

            Cheers
            I think I get what you are saying.

            I hadnt really known much or found interest in bindings but seems I asked a question that led me to them

            What I would like to see is example code. Where do I place this binding within my snippet or other place

            Eg, in my snippet, do I say

            $tvTemplatVariable@EVAL $modx->runSnippet("Ditto", array("tpl" => "<post><title>[+title+]</title><summary>[+summary+]</summary></post>"));

            where is the actual placement of the code?

            Let me also go through the documentation

            Thank-you
              • 7155
              • 160 Posts
              I am assuming that this is in the php code for the snippet
                • 3749
                • 24,544 Posts
                I think you have it backwards.

                The @eval $modx->runSnippet(’yourSnippetName’) is the actual TV, typed into the TV field in the Manager.

                Then, in your snippet you simply return the value that you want placed in the TV. The following code will put the URL of an image file in the TV:

                <?php
                
                $output = 'http://mysite.com/images/myimage.jpg';
                return $output;
                
                ?>
                  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
                  • 7155
                  • 160 Posts
                  Quote from: BobRay at Apr 17, 2009, 11:47 AM

                  I think you have it backwards.

                  The @eval $modx->runSnippet(’yourSnippetName’) is the actual TV, typed into the TV field in the Manager.

                  Then, in your snippet you simply return the value that you want placed in the TV. The following code will put URL of an image file in the TV:

                  <?php
                  
                  $output = 'http://mysite.com/images/myimage.jpg';
                  return $output;
                  
                  ?>

                  Thank-you. That was the missing bit!
                    • 3749
                    • 24,544 Posts
                    I’m glad you got it sorted. smiley
                      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