We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 813 ☆ A M B ☆
    • 326 Posts
    I’m using Ditto to generate a json file. Ditto does a nice job of grabbing TV values, but I would also like to create an item in the json file that combines the data from several other TVs on that same page.

    My idea was to use an @EVAL binding in the TV, but I’ve hit some snags. The TV default value looks like this:

    @EVAL global $modx; $params['id'] = '[*id*]'; return $modx->runSnippet('KeywordsAllGenerator', $params);


    The snippet I referenced (KeywordsAllGenerator) looks like this:

    <?php
    $output = '';
    
    $tvnames = array('keywords_general_q1');
    $tvoutput = $modx->getTemplateVarOutput($tvnames, $id, 1);
    $keywords_general_q1 = $tvoutput['keywords_general_q1'];
    
    $output = $keywords_general_q1;
    
    return $output;
    ?>


    Obviously there will eventually be more TVs in that $tvnames array and I’ll do more with the data -- I haven’t done anything with it yet because I can’t get the basic premise to work. With this code, I don’t get anything. What’s weird is, if I just return $id, I can see the correct ID number for each item that Ditto’s pulling from, so I think the @EVAL statement is correct.

    Any suggestions on what I’m doing wrong here?

    Thanks!