We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27408
    • 33 Posts
    This is a very small and simple snippet that I made. I use it in combination with getResources to get any tv of any resource in a quick and dirty way. There might be a better way that I never thought of or found out about. I’m posting it here so people can use it if they want.

    <?php
    if(!empty($ID) && is_numeric($ID)){
        if(!empty($name)){
          $doc = $modx->getObject('modResource', $ID);
          echo $doc->getTVValue($name);
        }else{
          echo 'Error: Name parameter is empty'; 
        } 
      }else{
        echo 'Error: Wrong or empty ID paramater'; 
      }
    ?>
    


    If you combine this with:

    [[!getResources? &parents=`1` &tpl=`exampleTpl`]]
    

    and:

    <li>[[+pagetitle]]</li>    
    <li>[[+id]]</li>          
    <li>[[!getTV? &ID=`[[+id]]` &name=`testTV`]]</li>
    <li>[[!getTV? &ID=`[[+id]]` &name=`testTV2`]]</li>
    

    You can list TV’s when showing a list of resources.

    (If there is a better way of doing this, don’t hesitate to share it here)