We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2762
    • 1,198 Posts
    How can i get the output of a snippet inside a TV?

    this is the example:

    I need a tv with value = Ditto author(createdby) to display inside the document (not in ditto tpl), in this way I can use the value to create a link to all post of written by x author(with new Ditto beta features wink).

    I have a tv called [*getauthor*] , value [*author*]
    I have a second tv [*author*], with value this snippet call [!UsernameLikeDitto? &createdby=$createdby!]


    the tv [*getauthor*] render the name of the author, but the value of tv still remain [!UsernameLikeDitto? &createdby=$createdby!]
      Free MODx Graphic resources and Templates www.tattoocms.it
      -----------------------------------------------------

      MODx IT  www.modx.it
      -----------------------------------------------------

      bubuna.com - Web & Multimedia Design
      • 11975
      • 2,542 Posts
      hi,

      you have to use @EVAL with your code in a row

      something like this should do the trick
      @EVAL $params['createdby'] = 'whatyouneed' ; return $modx->runSnippet('UsernameLikeDitto',$params);
      


      the main issue is to get the [*author*] value to pass it as a parameter

      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 2762
        • 1,198 Posts
        I need to put this code in [*getauthor*] tv and delete [*author*] tv?

        @EVAL $params['createdby'] = 'whatyouneed' ; return $modx->runSnippet('UsernameLikeDitto',$params);



        Thanks! wink
          Free MODx Graphic resources and Templates www.tattoocms.it
          -----------------------------------------------------

          MODx IT  www.modx.it
          -----------------------------------------------------

          bubuna.com - Web & Multimedia Design
          • 2762
          • 1,198 Posts
          @EVAL $params['createdby'] = 'createdby' ; return $modx->runSnippet('UsernameLikeDitto',$params);


          doesn’t work sad
            Free MODx Graphic resources and Templates www.tattoocms.it
            -----------------------------------------------------

            MODx IT  www.modx.it
            -----------------------------------------------------

            bubuna.com - Web & Multimedia Design
            • 11975
            • 2,542 Posts
            createdby must be the id returned from site_content table.
            That’s the hardest part of the job.
            Your can try with $modx->documentObject[’createdby’];

            @EVAL $params['createdby'] = $modx->documentObject['createdby'] ; return $modx->runSnippet('UsernameLikeDitto',$params);
            

            the code goes into default options value of the TV
              Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
              • 2762
              • 1,198 Posts
              Thanks a lot heliotrope

              Now works display Ditto author (ie: John Smith), but value of tv still remain the code(@EVAL $params....), not the output value (ie: John Smith) . undecided

                Free MODx Graphic resources and Templates www.tattoocms.it
                -----------------------------------------------------

                MODx IT  www.modx.it
                -----------------------------------------------------

                bubuna.com - Web & Multimedia Design
                • 11975
                • 2,542 Posts
                Could you post the UsernameLikeDitto snippet code that way I will test @home.

                :-)

                P.S: did you insert in the code in defaut option value ?

                EDIT:About the snippet code, I’ve found it in the forum. I don’t think there is a way to get the value of the @EVAL in QE using a TV with input type set to text
                  Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                  • 16429
                  • 254 Posts
                  Try to use a chunk as value, and put Ditto in the chunk.
                    kudo
                    www.kudolink.com - webdesign (surprised?)

                    [img]http://www.kudolink.com/kudolinkcom.png[/img] [sup]proudly uses[/sup] [img]http://www.kudolink.com/modx.png[/img]