I’ve been trying to get a simple plugin put together; I’ve searched high and low but cannot find any documentation explaining how to start new plugins from scratch, and where the document info is placed.
Basically I have a section of my site under a single folder, which is a sort of blog, sorted into folders, and a document for the entries - e.g. September 6th would be in /blog/2007/september/06.
What I want to do is create a document under the ultimate parent of /blog, fill only the subtitle in with the title of the blog entry, then when it’s saved, a plugin automatically fills in the menu title and alias as the current date (e.g. 06), and the title as the current date in a string (e.g. 6th September, 2007.)
If the saved document is a container, then fill in the month-name as the alias and menu title.
I’ve tried the following plugin:
switch($modx->Event->name)
{
case 'OnBeforeDocFormSave':
$modx->documentObject['content'] = date("d/m/Y H:i:s");
break;
case 'OnDocFormSave':
$modx->documentObject['content'] = date("d/m/Y H:i:s");
break;
default:
return;
break;
}
to set the document’s content to the current date, but when the document is saved, the content is still empty.
I know I could do this in the front-end with snippets based on the document’s published date, but then I’d just get lots of "Untitled documents" in the manager, and I’d rather not have to put this information into every document - it’d be much quicker to only have to type the content of the document and a title (plus I usually forget one or two details and have to go back and change them!)
What I’m looking for is what variables I can use in my plugins, what they represent, and how they’re used my MODx to interact with documents; I can’t find any information anywhere.
Any suggestions?
Thanks.
Andy.