This is a simple plugin on the event "OnDocFormSave".
It copies the pagetitle in the alias.
This works fine when I create a new resource.
But when I edit already created a resource, and click the Save button, then I don’t see results until I manually refresh the page.
How this problem can be solved?
if ($modx->event->name == 'OnDocFormSave')
{
if (!strlen($_POST['alias']))
{
$id = $scriptProperties['id'];
$alias = mysql_escape_string($_POST['pagetitle']);
$resource = $modx->getObject('modResource', $id);
/* do something */
$resource->set('alias', $alias);
$resource->save();
}
}
MODx version: Revolution 2.0.0-pl rev7212