We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6059
    • 45 Posts
    Hy, i have a snippet where I get different values from a resource over $modx->getObject(’modResource’, $id) and then with get() but how can I get the tv names this resource has access to?
      • 3749
      • 24,544 Posts
      Assuming that you have the $resource object with getObject(), this will get you an array of the TV objects:

      $tvs = $resource->getMany('TemplateVars');


      If it’s the current page, you don’t have to get it and can use this instead:

      $modx->resource->getMany('TemplateVars');


      Then you can get the names with:

      foreach ($tvs as $tv) {
          $tvName = $tv->get('name');
      }
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting