Answer the question
In order to leave comments, you need to log in
How to get migx data array?
How do I get an array of data from migx so that I can use it in a snippet. I need to make conditions there and it is very easy to work on php. But I don’t understand how to get an array, I understand that I need to give the correct query to the database, but I don’t know how. Is there anyone knows?
Answer the question
In order to leave comments, you need to log in
If we are talking about data that is saved in TV with the migx input field, then the output is JSON.
That is, the work will be something like this:
$doc = $modx->getObject('modResource', 15); // Получили объект ресурса с ID, например, 15
$migx_value = json_decode($doc->getTVValue('your_tv'), true); // получили значение TV и перекодировали из JSON в массив
{set $val = $_modx->resource.my_tv | json_decode : true}
// Любые операции, например, перебор
{foreach $val as $item}
<p>{$item.title}</p>
{/foreach}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question