Pages

Thursday, December 19, 2013

Get Migx TV values from resource in Modx Revo

Here is the code :

                    $docid = RESOURCE_ID; // id of current resource
                    $tvname = 'MultiColumn'; // Name of your TV
                    $tv = $modx->getObject('modTemplateVar', array('name' => $tvname));
                    $outputvalue = $tv->renderOutput($docid);
                    $items = $modx->fromJSON($outputvalue);
                    $idx = 0; // initialize idx
                    $output = array();
                    foreach ($items as $key => $item) {
                        $idx++; // increase idx
                        $output[] = print_r($item,1);
                    }
                    $outputSeparator = "\n";
                    $o = implode($outputSeparator, $output); // implode output

Here you will get all the value from Migx from any resource in arrays.

Comment it and Share it if it helps you.

1 comment:

  1. Hey, I would like to add a record to the Migx TV through a snippet. Any idea how to do that?

    ReplyDelete