We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3232
    • 380 Posts
    I am trying to propagate a grid with some custom data. I have come up with the following code and I get a total number results but the result is always empty in the json response.

    getlist processor:

    $isLimit = !empty($scriptProperties['limit']);
    $start = $modx->getOption('start',$scriptProperties,0);
    $limit = $modx->getOption('limit',$scriptProperties,10);
    $sort = $modx->getOption('sort',$scriptProperties,'name');
    $dir = $modx->getOption('dir',$scriptProperties,'ASC');
    $query = $modx->getOption('query',$scriptProperties,'');
    
    $c = $modx->newQuery('modUser');
    $c->leftJoin('modUserProfile','Profile');
    $c->select('modUser.username, Profile.fullname');
    
    $count = $modx->getCount('modUser', $c);
    
    $c->sortby($sort,$dir);
    $resources = $modx->getCollection('modUser',$c);
    
    $list = array();
    foreach ($resources as $resource) {
        $resourceArray = $resource->toArray();
        $list[] = $resourceArray;
    }
    
    return $this->outputArray($list,$count);


    never returns results but returns a total count.

    {"total":"7","results":[]}


    I assume I am missing something very basic. Once I get this working, I plan on using a getMany on the foreach so that I can pull in items from a custom table.

    Thanks,
    Brian