We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24806
    • 43 Posts
    Heyho,
    I am very new to MODx - but I love it!!!
    So far so good. I want to get the Output of a special TemplateVar of another page but I cannot find the command for this. I’ve found the function getTemplateVarOutput on the Wiki but nobody has written sth about it, so that I do not know how to use it.
    Perhaps you can tell it to me. All in all: need snippet to get the TemplateVar of a page with certain id.

    greetings
    Max
      I love MODx
      • 28042 ☆ A M B ☆
      • 24,524 Posts
        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
        • 7231
        • 4,205 Posts
        ReMaX: do you need to access this TV within a snippet? You can easily use the GetField snippet for this.

        http://www.modxcms.com/getField-667.html
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don't know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 24806
          • 43 Posts
          Thanks a lot, guys! I think I got it. Summary:
          Array = $modx->getTemplateVarOutput(’-templatevarname-’, -documentid-);
          <?php
          $output = isset($docid) ? $modx->getTemplateVarOutput('docimg',$docid) : '';
          return $output['docimg'];
          ?>
          
            I love MODx
            • 10313
            • 375 Posts
            This exactly is the way i’m trying to use getTemplateVarOutput. But the result is not the rendered output but the stored value. The TV is of type listbox (multi-select). So the stored value is for example 1||3||4. The Output value should be something like "name1||name3||name4", but I only get "1||3||4". Is there any way to receive the rendered output?

            Martin
              • 24806
              • 43 Posts
              try this...
              $output = isset($docid) ? $modx->getTemplateVarOutput('docimg',$docid) : '';
              return $modx->parseDocumentSource($output['docimg']);
              
                I love MODx
                • 10313
                • 375 Posts
                Quote from: DevilOpa at May 20, 2008, 12:05 PM

                try this...
                $output = isset($docid) ? $modx->getTemplateVarOutput('docimg',$docid) : '';
                return $modx->parseDocumentSource($output['docimg']);
                


                This makes my "1||3||4||5" to "1345". I’m sure I have an error in this, but I don’t know where ...

                Martin
                  • 36592
                  • 970 Posts
                  Quote from: FuryDE at May 20, 2008, 03:46 AM

                  The TV is of type listbox (multi-select). So the stored value is for example 1||3||4. The Output value should be something like "name1||name3||name4", but I only get "1||3||4". Is there any way to receive the rendered output?
                  I guess you set the input option value of the TV something like ’name1==1||name2==2||name3==3||name4==4’.
                  In this case the stored value of the TV is like ’1||3||4’, so your result is correct.

                  If you need something like ’name1||name3’ of your output from the TV, you have to set the input option value like ’name1||name2||name3||name4’.
                    • 10313
                    • 375 Posts
                    Quote from: tkfm at May 21, 2008, 02:41 AM

                    I guess you set the input option value of the TV something like ’name1==1||name2==2||name3==3||name4==4’.
                    In this case the stored value of the TV is like ’1||3||4’, so your result is correct.

                    Exactly. But I would not think, that the result is correct, because -- in my opinion -- the rendered output should be the readable values of the TV.

                    Martin