We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28120
    • 380 Posts
    I'm using a multi-select box for related pages using

    http://rtfm.modx.com/display/revolution20/Creating+a+multi-select+box+for+related+pages+in+your+template

    This all works great except I'm not able to display a TV value from a related page.

    How do I modify the code below to also include TV values?

    if (empty($input)) { return 'This article is so unique, that we couldn\'t find anything related to it!'; }
    $tpl = $modx->getOption('tpl',$scriptProperties,'relatedPagesTpl');
    if ($modx->getChunk($tpl) == '') { return 'We found some related pages, but don\'t know how to present it.'; }
    $ids = explode(',', $input);
    $output = array();
    foreach ($ids as $key => $value) {
      $resource = $modx->getObject('modResource',array(
        'published' => 1,
        'id' => $value));
      if ($resource instanceof modResource) {
        $output[] = $modx->getChunk($tpl,$resource->toArray());
      }
    }
    return implode('',$output);
    


    Thanks
      • 3749
      • 24,544 Posts
      Try this:

      if ($resource instanceof modResource) {
          $fields = $resource->toArray();
          $fields['TvPlaceHolderName'] = $resource->getTVValue('TvName');
          $output[] = $modx->getChunk($tpl,$fields);
        }


      If you replace 'TvName' with the ID of the TV, it will be a little faster.
        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
        • 36830
        • 140 Posts
        whats the distinction between the tvplaceholder name and the tvname here? having the same problem and this seems to be a viable solution...
          • 4172
          • 5,888 Posts
          you have to replace TvName with the name of your TV and TvPlaceHolderName with the Name for your placeholder

          if your TV-name is myTV and you use

          $fields['myTV'] = $resource->getTVValue('myTV');


          you can use this placeholder in your chunk:

          [[+myTV]]
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!