Skip to content

Instantly share code, notes, and snippets.

@dubrod
Created November 30, 2018 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dubrod/c93d7599ebee27a99247b908324d9783 to your computer and use it in GitHub Desktop.
Save dubrod/c93d7599ebee27a99247b908324d9783 to your computer and use it in GitHub Desktop.
QUERIES
$resources = $modx->getCollection('modResource', array('published'=>'1','hidemenu'=>'0','isfolder'=>'1','parent'=>'16','class_key'=>'modDocument'));
foreach($resources as $resource) {
$id = $resource->get('id');
$thumb = $resource->getTVValue('thumbImage');
}
OR--
$q = $modx->newQuery('modResource');
$q->where(array('published'=>'1','hidemenu'=>'0','isfolder'=>'1','parent'=>'16','class_key'=>'modDocument'));
$q->sortby('menuindex','ASC');
$resources = $modx->getCollection('modResource',$q);
OR---
$modx->getObject('modResource', 555);
WITH DEPTH----
$parent = 20;
$depth = 3;
$childs = $modx->getChildIds($parent,$depth);
$c = $modx->newQuery('modResource');
$c->where(array('published'=>1));
$c->where(array('id:IN'=>$childs));
$c->sortby('id','DESC');
$c->limit(3);
$children = $modx->getCollection('modResource',$c);
----
$id = $modx->getOption('id', $scriptProperties);
$modx->log(modX::LOG_LEVEL_ERROR,'getLatLong was run: ' . $data);
//set placeholder
$modx->setPlaceholders(array(
'name' => 'John',
'email' => 'jdoe@gmail.com',
),'my.');
//make url
$url = $modx->makeUrl(4);
$siteStartId = $modx->getOption('site_start');
$key = "Topgolf Orlando";
$ctx = $modx->getContext($key);
if ($ctx) {
return $ctx->getOption('upcoming_hours_placeholder', null, 'default');
} else {
/* context doesn't exist */
}
//MIGX value in a snippet
$sec_answers = $modx->fromJSON($sec->getTVValue('quizy_answers'));
foreach($sec_answers as $ans) {
$ans_output .= $modx->getChunk('quizy-answer-row',array('text' => $ans["answer"]));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment