We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6516
    • 2 Posts
    Hello and thanks for your time.

    I am creating a website on Evolution, and I need to use different templates for different major sections of the site. Problem is that I want to post information from a TV on a page that’s using a different template. I use a chunk and reference the template variable like this: [*tvPhoto*]. Nothing happens. It’s like the TV is not defined.

    Question: How do I access a TV from a page that’s using a different template? I’m cool with using PHP, if that’s what it takes. I was hoping I could just do something like, [*tvPhoto@otherTemplate*].

    Yeah, I’m a newbie. :-D

    Thanks,
    Dan
      • 4310
      • 2,310 Posts
      A quick snippet to do the job :
      <?php
      $page_id = isset($page_id)?$page_id: 1;
      $tv_name = isset($tv_name)?$tv_name: 'tvName';
      $tv = $modx->getTemplateVarOutput(true, $page_id);
      $value=$tv[''.$tv_name.''];
      return $value;
      ?>

      Where $page_id is the document id & $tv_name is the TV name, of the document you are retrieving the tv value from.
      Example snippet call:
      [!TVData? &tv_name=`tvPhoto` &page_id=`87`!]
        • 6516
        • 2 Posts
        Nevermind! When a newbie enters the domain, confusion reigns.

        I was using Ditto to summarize entries within a different section of the site, and using a chunk to format those summaries. Then ... in the chunk ... I attempted to access TVs from the documents I was summarizing; of course the result was empty, because the chunk was trying to access the TV from the page that was rendering the summary, not the pages that were being summarized.

        Oops.
          • 6516
          • 2 Posts
          David,

          Thanks for the snippet code. I also tried something I found from Bruno17. http://modxcms.com/forums/index.php?topic=40862.0 Simply reference the TV within the chunk called by the Ditto placeholder like this: [+tvname+]. This seems to work for my purposes.

          Best regards,
          Dan
            • 4310
            • 2,310 Posts
            [+tvname+] is correct for Ditto retrieving document’s tv.
            I thought you were trying to access it directly with your own snippet.