ModX Rest Api and parsing tags

Hey all,

I am building a REST API and I am building an object Array. I’m attempting to use runSnippet “getimagelist” to return a value but it is not parsing the tpl. Here’s my code:

$objectArray = array(
    	    'id' => $id,
    	    'filters' => $this->object->getTVValue(2),
    	    'banner' => $this->modx->runSnippet('getImageList', [
                'tvname' => 'bg_img',
                'tpl' => 'RESTbg_slideTpl',
                'limit' => '1',
                'where' => '{"published:=":"1"}',
            ])
    	);	

and this is the response that I got back

{"success":true,"message":"","object":{"id":"208","filters":"bb||ag||aw||bs||bs2||cw||bm||gd||lc||tt||ky||kn||bq||ht||gy||bl||mf||tc","banner":"[[!+image_bg]]"},"code":200}

Any ideas why it is not parsing the chunk? Also, I noticed that if I dont include an instance of “$this->object->getTVValue(somevalue)” within my object, the runsnippet does not run and I get an empty return.

$objectArray = array(
    	    'id' => $id,
    	    'banner' => $this->modx->runSnippet('getImageList', [
                'tvname' => 'bg_img',
                'tpl' => 'RESTbg_slideTpl',
                'limit' => '1',
                'where' => '{"published:=":"1","servicecountries:find_in_set":"bb"}',
            ])
    	);	

Result

{"success":true,"message":"","object":{"id":"208","banner":""},"code":200}

Why would that happen?

Does it work if you supply the &docid property in your call to getImageList? Otherwise I suspect the snippet tries to access $modx->resource that is not set in your API endpoint.


Is only the uncached content of the chunk not parsed?

1 Like

Sigh…yes it was simple as forgetting to add &docid. I am also having some other issues running a custom snippet but it is probably some logic error. Thanks for the assist.