I'm working on a plugin that responds to TV values and, when a new resource is created (under certain conditions), instantly creates certain child resources under that new resource.
I want to explicitly set the values in certain fields (pagetitle, alias, template, published, searchable, etc.)
My question is, do I need to explicitly set the values in ALL the fields? Are there ones I can safely skip, which will get default values? Are there fields I must explicitly set?
I'm probably going to just do some experimenting, but I'm hoping someone can give me some good advice to get me started in the right direction.
$fields = array(
'pagetitle' => 'Foo bar',
'alias' => 'foo-bar',
'content' => 'Fooooooo bar!'
);
$response = $modx->runProcessor('resource/create', $fields);
if ($response->isError()) {
return 'Oops!';
} else {
// Success!
}
-
- 483 Posts
Quote from: jrotering at Feb 21, 2013, 07:52 PMI can also verify that if you put code like this into an OnDocFormSave plugin, and you aren't careful about checking your conditional statements, you can create A WHOLE LOT OF RECURSIVE RESOURCES VERY QUICKLY with this code!
Yuppers! I learned that one myself. I use API created documents quite extensively.