ok, so looking into the code further...
I can (sort of) make my blog post have the correct archive uri when it is published by hacking around in the ArticlesPlugin
case 'OnDocPublished':
/** @var Article $resource */
$resource =& $scriptProperties['resource'];
if ($resource instanceof Article) {
$resource->setArchiveUri();
$resource->save();
$resource->notifyUpdateServices();
$resource->sendNotifications();
}
break;
This takes care of the case where you click 'publish' from the articles container or the top button bar on an actual article.
To handle the case where you select the Publish option from the dropdown menu, I had to alter the both the beforeSave functions in ArticleCreateProcessor
public function beforeSave() {
$beforeSave = parent::beforeSave();
if (!$this->parentResource) {
$this->parentResource = $this->object->getOne('Parent');
if ($this->parentResource) {
$this->object->set('articles_container',$this->parentResource->get('id'));
}
}
// if ($this->object->get('published') || $this->isPublishing) {
// if (!$this->setArchiveUri()) {
// $this->modx->log(modX::LOG_LEVEL_ERROR,'Failed to set URI for new Article.');
// }
// }
//
/** @var ArticlesContainer $container */
$container = $this->modx->getObject('ArticlesContainer',$this->object->get('parent'));
if ($container) {
$settings = $container->get('articles_container_settings');
$this->object->set('articles_container_settings',$settings);
$this->object->set('richtext',!isset($settings['articlesRichtext']) || !empty($settings['articlesRichtext']));
}
$this->isPublishing = $this->object->isDirty('published') && $this->object->get('published');
if ($this->object->get('published') || $this->isPublishing) {
if (!$this->setArchiveUri()) {
$this->modx->log(modX::LOG_LEVEL_ERROR,'Failed to set URI for new Article.');
}
}
return $beforeSave;
}
and ArticleUpdateProcessor
public function beforeSave() {
$afterSave = parent::beforeSave();
// if ($this->object->get('published') || $this->isPublishing) {
// if (!$this->setArchiveUri()) {
// $this->modx->log(modX::LOG_LEVEL_ERROR,'Failed to set URI for new Article.');
// }
// }
//
/** @var ArticlesContainer $container */
$container = $this->modx->getObject('ArticlesContainer',$this->object->get('articles_container'));
if ($container) {
$this->object->set('articles_container_settings',$container->get('articles_container_settings'));
}
$this->isPublishing = $this->object->isDirty('published') && $this->object->get('published');
if ($this->object->get('published') || $this->isPublishing) {
if (!$this->setArchiveUri()) {
$this->modx->log(modX::LOG_LEVEL_ERROR,'Failed to set date URI.');
}
}
return $afterSave;
}
All I'm doing here is also checking to see if the isPublishing flag is true, in which case call the setArchiveUri method.
Now, the sendNotifications & notifyUpdateServices both use the same code
$url = $this->xpdo->makeUrl($this->get('id'),$this->get('context_key'),'','full');
in my case, this will always return '' for an article created/published & saved in one go, or /blog/alias for a previously saved article. There doesn't seem to be anything in the code to take into account the archive Uri that has been forced on this blog post.
Now, I'm very aware that I don't fully understand the Articles code yet, so the above is intended as a write up of my analysis.
Please don't use it - it still doesn't work and I may be totally off on how I'm trying to fix it.