We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12241
    • 80 Posts
    Hi all, I’m working on a custom snippet that is setup to display a chunk with placeholders that are filled with the values of TV’s from another modx resource. My snippet call looks like this:
    [!Video? &id="[the id of resource to pull TVs from]"!]


    The code in my snippet which pulls up the Template Variables from the document using the &id parameter from the snippet call looks like this:
    <?php
    // example snippet call = [!Video? &id=`74`!] 
    
    $tvArray = array('video_id','video_width','video_height','introtext','pagetitle','longtitle'); //array of the TV names I want to retrieve
    
    //$docID = 70; //<- WORKS 
    $docID = $id;//<- NO WORK
    print_r($id);//outputs: 74
    print_r($docID);//outputs: 74
    
    $tvs = $modx->getTemplateVars($tvArray,'*',$docID);
    print_r($tvs);//to test if working
    
    



    The problem I’m running into is that when $docID is hard coded to a numeric value the modx->getTemplateVars call works... but when I assign the value of $docID to the value of my $id snippet parameter it doesn’t work... I get no results.

    I’m still a bit of a php newb so please forgive me if I’m doing something dumb...

    many thanks to the kind soul here who has any advice / input / clarification on how I can achieve my goal...

      Environment:
      modx: rev 2.0.8-pl
      localhost: Apache/2.0.63 (Unix) PHP/5.2.11 DAV/2, MySQL client version: 5.1.37
      • 12241
      • 80 Posts
      NEVERMIND --- it was really dumb --- the id number I was using to test this did not exist. Doh! tongue
        Environment:
        modx: rev 2.0.8-pl
        localhost: Apache/2.0.63 (Unix) PHP/5.2.11 DAV/2, MySQL client version: 5.1.37