Quote from: opengeek at Jul 05, 2012, 08:48 AMQuote from: EvoBunny at Jul 05, 2012, 08:30 AMI programmatically creates resources and then sets the pub_date. The resource is part of 'n list which wayfinder loads. The resource then never gets added to the wayfinder/menu list even if it's beyond the pub_date.
My first guesses would be perhaps you are not programmatically creating the Resource correctly, or, your Wayfinder calls are caching results that are not getting updated when the auto_publishing activity occurs. Are you using multiple Contexts by chance?
When calling wayfinder did put in the ! so that it doesn't load the cached version, i.e.
We are only using one context which is the default 'web' context.
My steps when creating the resources is as follow:
$resource = $event->getOne('Resource');
if (!is_object($resource)) {
$resource = $modx->newObject('modResource');
$resource->set('createdby', $modx->user->get('id'));
$resource->set('createdon', $currentDate->getTimestamp());
$resource->set('parent', 15);
$resource->set('template', 6);
$resource->set('published', 0);
$event->addOne($resource);
} else {
$resource->set('editedby', $modx->user->get('id'));
$resource->set('editedon', $currentDate->getTimestamp());
}
$resource->set('pagetitle', $name);
$resource->set('alias', $resource->cleanAlias($resource->get('pagetitle')));
$date = new DateTime($publishDate);
$resource->set('pub_date', $date->getTimestamp());
The resource is an aggregate of the event object and the event object is saved later down the line. Should I be saving the resource object first? Or is that not necessary?