Skip to content

Instantly share code, notes, and snippets.

@dubrod
Created November 30, 2018 00:54
Show Gist options
  • Select an option

  • Save dubrod/c93d7599ebee27a99247b908324d9783 to your computer and use it in GitHub Desktop.

Select an option

Save dubrod/c93d7599ebee27a99247b908324d9783 to your computer and use it in GitHub Desktop.

Revisions

  1. dubrod created this gist Nov 30, 2018.
    68 changes: 68 additions & 0 deletions modx-snippet-notes
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,68 @@
    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"]));
    }