We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33453
    • 141 Posts
    I am trying to get hold of the document’s [*mainCopy*] in a snippet and I have tried everything I can think of: getTemplateVar, getPlaceholder, and documentObject[’variable-name’] with no success.

    Can anyone point me in the right direction?

    Thanks.
    • What do you mean by [*mainCopy*}? There is no such default document variable. Do you mean [*content*]? Or have you created a TV called mainCopy, and are trying to access its value for the current document? In the latter case, try getTemplateVarOutput. It looks like you need to feed it an array, even if you are only after the output of one TV:

      # returns an associative array containing TV rendered output values. $idnames - can be an id or name that belongs the template that the current document is using
      function getTemplateVarOutput($idnames=array(), $docid="", $published=1) {
      if(count($idnames)==0) {
      return false;
      }
      ...
        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
        • 33453
        • 141 Posts
        Quote from: sottwell at Jun 04, 2006, 03:09 AM

        Or have you created a TV called mainCopy, and are trying to access its value for the current document?
        No - it’s not one of mine, but there it is in the template,large as life:
        <div id="block_1">
          <h2>review</h2>
          <div class="box article">
            <img src="[*StoryImage*]" alt="Story Illustrative Photo"/><h2>[*pagetitle*]</h2>[[AuthorTime]]
          >>[*#mainCopy*]<<
          </div>
        </div> <!-- block 1 -->
        
        and it works - even though it is not defined ANYWHERE huh.

        However, you are correct, Susan, it is just [*content*] under an assumed name - and getTemplateVarOutput is the way to go.

        Thanks.