We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26163
    • 43 Posts
    If I have some TVs assigned to a blank template, how do I display those TV values to resources where other template has been assigned?

    In summary, I have done this. I have created a blank template and assigned some TVs to it so only the resource where the blank template has been assigned gets the TV. Now I want the values of those TVs to appear in other resources where some other template has been assigned. By using [*TVName*], I am not getting the value. Any help is appreciated.
      • 3109 ☆ A M B ☆
      • 894 Posts
      In Revo you would do that with getResourceField, I don’t know if there’s an equivalent in Evo to getResourceField.
        Benjamin Marte
        Interactive Media Developer
        Follow Me on Twitter | Visit my site | Learn MODX
        • 26163
        • 43 Posts
        Thanks benmarte, but I use evo. I wonder if they have something equivalent.
          • 3109 ☆ A M B ☆
          • 894 Posts
          #kunane on twitter suggested you try this plugin seems to be the Evo equivalent of getResourceField
            Benjamin Marte
            Interactive Media Developer
            Follow Me on Twitter | Visit my site | Learn MODX
            • 26163
            • 43 Posts
            It works, but I cannot use phx with this plugin. sad
              • 4310
              • 2,310 Posts
              Here is a quick demo snippet that will get a number of TV values from a given document id.
              You can then manipulate the value before returning it for display without using PHX.
              In this example : format a number, create a link url and return an image with width & height.
              Hopefully you can make it do what you need smiley

              <?php
              $output = '';
              $page_id = isset($page_id)?$page_id: 87;
              $myArray = $modx->getTemplateVarOutput(array('firstTv','secondTv','thirdTv'), $page_id);
              
               if(!empty($myArray['firstTv']) && is_numeric($myArray['firstTv'])){
               $formatted_number = number_format($myArray['firstTv']);
               $output .='<b>$'.$formatted_number.'</b>';
               }
               
               if(!empty($myArray['secondTv']) && is_numeric($myArray['secondTv'])){
               $link_url = $modx->makeUrl($myArray['secondTv'], '', '', 'full');
               $output .='<a href="'.$link_url.'" title="Related link">Related link</a>';
               }
               
               if(!empty($myArray['thirdTv']) && file_exists($myArray['thirdTv'])) {
               $info = getimagesize($myArray['thirdTv']);
               $width = $info['0'];
               $height = $info['1'];
               $output .='<img src="'.$myArray['thirdTv'].'" width="'.$width.'" height="'.$width.'" />';
               }
               
              return $output;
              ?>