We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37929
    • 18 Posts
    Hello I built a snippet that lists the links to the related translations of the current page accross several contexts.

    How i fetch the datas :
    
                $wordsTranslations = $modx->getCollection('modResource',$c);
    
                foreach ($wordsTranslations as $wordsTranslation) {
    
    
                    $modx->setPlaceholders(array(
                       'language'   => $resourcesIdsArr[$i][0],
                    ),$placeholders_prefix);
    
                    $resourceArray = $wordsTranslation->toArray();
    
                    $output .= $modx->getChunk($wordTpl,$resourceArray);
    
                }
    

    The template chunk :
    <li>
    <a href="[[~[[+id]]]]" title="[[+introtext]]">[[+pagetitle]]</a>
    [[*type]] - [[*word_register]]
    </li>
    


    I can retrieve placeholders and pagetitles but not the TVs... Shouldn't the tvs be loaded automatically ? They should but what could be wrong huh

    global cache is off

    [ed. note: tulavu last edited this post 12 years, 3 months ago.]
      • 4172
      • 5,888 Posts
      you can try this:

      $wordsTranslations = $modx->getCollection('modResource',$c);
       
      foreach ($wordsTranslations as $wordsTranslation) {
       
       
          $modx->setPlaceholders(array(
             'language'   => $resourcesIdsArr[$i][0],
          ),$placeholders_prefix);
       
          $resourceArray = $wordsTranslation->toArray();
         
          $tvs = (type,word_register);
          $tvs = explode(',',$tvs);
          foreach ($tvs as $tv){
              $resourceArray[$tv] = $wordsTranslation->getTVValue($tv);  
          }
      
          $output .= $modx->getChunk($wordTpl,$resourceArray);
       
      }
      


      <li>
      <a href="[[~[[+id]]]]" title="[[+introtext]]">[[+pagetitle]]</a>
      [[+type]] - [[+word_register]]
      </li>


        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!