Greetings. I’m looking to retrieve a snippet’s id based on its name. Would you use a query ala
$c = $modx->newQuery('modSnippet');
$c->where(array(
'name' => 'snippetname'
));
$resource = $modx->getOne('modSnippet',$c);
$id = $resource->get('id');
Or, is there an easier way to do this?
------
Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.
Quote from: smg6511 at Mar 31, 2011, 01:46 PM
Greetings. I’m looking to retrieve a snippet’s id based on its name. Would you use a query ala
$c = $modx->newQuery('modSnippet');
$c->where(array(
'name' => 'snippetname'
));
$resource = $modx->getOne('modSnippet',$c);
$id = $resource->get('id');
Or, is there an easier way to do this?
$snip = $modx->getObject($modSnippet, array('name'=> $name));
$id = $snip->get('id');
Thanks a bunch, Bob. I figured there was a shorter path to what I wanted!
------
Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.