Hi there,
I am fairly new to the Modx community and was looking for some support with an obscure error that I am encountering. I have Modx Revo 2.2 installed on my Windows XP machine and am running from xampp locally (PHP version 5.3.8, mysql 5.0.8, apache 2.2). I am working on a piece of functionality that will create a new child resource automatically whenever the parent resource is selected in the resource tree. I have a custom plugin that handles this logic just fine, but it only seems to work when delete my cache. So, on executing this code with no cache it works, but a new cache is subsequently created when the plugin runs. When I try to run the plugin again with a cache in place, I get the following error:
An error occurred: {"modx-resource-tree":["\/root\/web_0"],"undefined-sort-default":"menuindex","undefined-sort":"menuindex"}
I am unsure as to what this error means exactly and how to go about fixing it. I know that it caused by the cached version of the plugin being called as the error doesn't occur when I clear the cache. I have tried forcing the cache to clear itself each time the plugin is executed, just as a temporary solution to continue development, but this seems to have no effect. Has anyone encountered this sort of error before? I would appreciate any advice that can be given. The code for the plugin is as follows:
if ('my-resource' == $resource->get('alias')) {
$gtpl = $modx->getObject('modTemplate', array('templatename' => 'mytemplate'));
// Create the suggested table folder
$fields['createdby'] = $modx->user->id;
$fields['parent'] = $id;
$fields['template'] = $gtpl->get('id');
$fields['alias'] = 'aliasname';
$fields['uri'] = 'uriname'.md5(time());
$fields['isfolder'] = 0;
$fields['uri_override'] = 1;
$fields['hidemenu'] = 0;
$fields['pagetitle'] = 'mypagetitle';
$fields['published'] = 1;
$fields['show_in_tree'] = 0;
$response = $modx->runProcessor('resource/create', $fields);
if ($response->isError()) { /* An error occurred */
if ($response->hasFieldErrors()) {
$fieldErrors = $response->getAllErrors();
$errorMessage = implode("\n", $fieldErrors);
} else {
$errorMessage = 'An error occurred: ' . $response->getMessage();
}
$modx->log(xPDO::LOG_LEVEL_ERROR,$errorMessage);
echo $errorMessage;
die;
} else {
$modx->cacheManager->refresh();
}
}
Thank You
[ed. note: bluesteel last edited this post 14 years ago.]