I finally found the time to look at how the process I suggested affects the database. Unless you set them explicitly, the
publishedon (if you set
published to 1) fields are not set. The
automatic_alias System Settings are ignored, as are the other defaults like
In addition, the normal events,
OnDocFormSave are not fired, so any plugins attached to those events will not execute.
A much better method is to just use the
/* Article Creation Code */
$articleFields = array(
/* set this to the ID of an Articles Container */
'parent' => 12, /* Required */
/* set this to the ID of the Article Template
(*not* the Articles container template) */
'template' => 122, /* Required */
'pagetitle' => 'Blog5', /* Required */
'class_key' => 'Article', /* Required */
'content' => '<h3>Blog 5</h3>', /* Optional */
The other fields will be set automatically, though you’re free to set them yourself if you don’t want the defaults or have other fields to set (e.g.,
The System Setting defaults (including
automatic_alias) will be honored.
And if you set
publishedby fields will be set.
You may also want to set the
publishedby fields to the ID of a user other than the admin.
The events will be fired and any relevant plugins will execute.
Note that the process may throw a few harmless warning and info messages, but normally, you won’t see them.