Working on migrating a site from evolution to revolution. Have used modX before but it;s been a while, and I didn't run into this problem last time. I can't use
$modx->getCollection('modResource',$c); in my code - I get a PHP error:
Fatal error: Call to a member function getCollection() on a non-object in [path-to-root]/core/cache/includes/elements/modsnippet/17.include.cache.php on line 21
Here is the snippet:
<?php
global $modx;
$modx->resource =& $document;
$id = $modx->resourceIdentifier;
$arr = array("parent" => $id, "published" => 1, "deleted" => 0);
$c = $modx->newQuery('modResource');
$c->where(array(
'parent:IN' => array(23,24,25),
'deleted' => false,
'hidemenu' => false,
'published' => true,
));
$c->sortby('menuindex','ASC');
$c->limit(10);
$resources = $modx->getCollection('modResource',$c);
$children= $modX->getCollection('modResource', $arr);
if (!$children === false) {
$firstChild= $children[0];
$firstChildUrl= $modx->makeUrl($firstChild['id']);
} else {
$firstChildUrl= $modx->makeUrl($modx->config['site_start']);
}
return $modx->sendRedirect($firstChildUrl);
The lines don't match up obviously, and I'm trying to debug it so that's why the code is not actually reasonable and has two parts that would do the same thing, but I'm wondering why modResource is giving me the non-object error? II can't find any instructions on initializing it (sorry if my terminology is off) for snippets but I assume that it's not defined.
Thanks for any help you can provide. I am using PHP v5, modx version 2.1.3-pl (traditional)