Created
January 23, 2019 12:35
-
-
Save aisteron/51c4d4facaf018bc1afa69a1876b8165 to your computer and use it in GitHub Desktop.
modx ajax snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*$page = $modx->getObject('modResource', 13); | |
$chars = json_decode($page->getTVValue('chars')); | |
echo '<pre>'; | |
foreach($chars as $k => $v) | |
{ | |
echo $v->key0.'-'.$v->value0; | |
} | |
return;*/ | |
$where = array( 'parent' => 6 ); | |
$resources = $modx->getCollection('modResource',$where); | |
$cars = []; | |
foreach ($resources as $k => $res) { | |
//echo $modx->getObject('modResource', $k)->getTVValue('chars').'<br><br>'; | |
/*$res = $modx->getObject('modResource', $k)->getTVValue('chars'); | |
echo '<pre>'; | |
print_r(json_decode($res));*/ | |
//echo '<pre>'; | |
//print_r($res->get('uri')); | |
$cars[$k]['uri'] = $res->get('uri'); | |
$cars[$k]['pagetitle'] = $res->get('pagetitle'); | |
$page = $modx->getObject('modResource', $k); | |
$chars = json_decode($page->getTVValue('chars')); | |
foreach($chars as $key => $v) | |
{ | |
//echo $v->key0.'-'.$v->value0; | |
$cars[$k][$v->key0] = $v->value0; | |
} | |
} | |
//echo '<pre>'; | |
//print_r($cars); | |
echo json_encode($cars); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment