Hi all,
I ran into a bug(?) when trying to create a modResource programmatically.
I use the following script:
(
user = logged in, check
$parentId = set, check
$templateId = set, check
$rq['pagetitle'] = set, check
)
$page = $modx->newObject('modResource');
$page->set('createdby', $modx->user->id);
$page->set('createdon', time());
$page->set('parent', $parentId);
$page->set('template', $templateId);
$page->set('alias', $page->cleanAlias($rq['pagetitle']));
// $page->set('uri', $page->cleanAlias($rq['pagetitle']).".html");
// $page->set('uri_override',1);
$page->set('hidemenu',1);
$page->set('menuindex',count($modx->getCollection('modResource',array('template'=>$templateId))));
$page->set('pagetitle', $rq['pagetitle']);
$saved = $page->save();
it throws the following error:
[21-Feb-2012 13:08:25] PHP Fatal error: Call to a member function getOption() on a non-object in /..../core/model/modx/modresource.class.php on line 853
Using 2.2.0-pl2(traditional)
Adding the uri & uri_override makes the modresource.class.php skip the routine containing line 853 and makes it possible to create a modResource just fine except that I do not want to override the default URI...
Any ideas or might this be a bug?
Thanks!