K
K
KirSupi2020-10-21 02:13:33
MODX
KirSupi, 2020-10-21 02:13:33

How to insert JSON from MIGX into a page using modParser?

It is necessary to display the value of the TV field MIGX in the form of JSON on the site (so that it is in the JS that is on the page, but this is not so important). How to do it?
I know that it is possible through Fenom, but then you have to redo too much code from to {$_modx}.

For those who know PHP and/or JS, but don't know MODX:
There is text on the page that can't be rendered with PHP:

Array
(
    [MIGX_id] => 2
    [theimg] => 123
    [thelink] => ItIsAStringElement
    [_alt] => 0
    [_first] => 1
    [property.tvname] => testMIGXTV
)

You have to transfer it somehow.
test.php

return json_decode( как-бы-input );

and get JSON back.
How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DLSamson, 2021-12-20
@DLSamson

Instead of outputting getImageList , try simply getting the value of the TV field via the snippet.

$page = $modx->getObject('modResource',  array('id'=>'123'));
$output = $page->getTVValue('migxField');
echo $output;

We get a conditional output:
[{"MIGX_id":"1","image":"123123","title":"qwe","rating":"qwe","active":"1"}]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question