I may be wrong, but it is my impression that the publish date is only set when using the publish date field. Is there a way to get the pub date to be filled when a document is put in the published state? Can this be done with a plug-in?
You’re not wrong, that’s something which could be improved indeed if the published date could be set by default as the createdon date... I am not qualified but I’d say it could be done with a plugin listening to "OnDocPublished" or "OnDocFormSave"
.: COO - Commerce Guys - Community Driven Innovation :.
MODx est l'outil id
I’m not sure what purpose it would serve (though maybe there’s a good reason you want this that I’m not thinking of). If you want all documents published when created, you can set the default for new docs to published.
Once the "published" checkbox is checked, the doc is published regardless of the "published" date.
IOW, the "published" date is only relevant if you want a document to remain unpublished after you create it. If you want to refer to the date the doc was created, you have the "created on" date.
On second thought, I guess if it worked as DavidM has suggested, we wouldn’t have to explain to users that they didn’t have to fill in the published date when creating documents.
my problem is the following - i have news published at a sertain time in the future and then autoticaly emailed
in ditto listing i have pub_date date source and it uses createdon if no pub_date is set - that’s OK.
But in the news itself i have date show via [*pub_date*] and if no pub_date set it writes 01.01.1970 (using FormatDate snippet)
I realy need it to be inherited because i’m tired of writing pub_date manualy each and every time even when i dont’t have it to be published in the future.
may be some of the gurus can help me?
the only way i see is to write a snippet which will look for pub_date if there’s none it will use createdon but i hope there is better and simplier way.
One way would be to create a plugin that listens to the OnBeforeDocFormSave event and fills the current date (or duplicates the "created on" date) in the pub date field only if there’s nothing there already, although then the only way to save a document without it being published immediately would be to enter a future date the field. I guess you might be able to have the plugin act only if "now" were in the field -- that would be easier than entering a date at least.
Maybe someone else has a better idea.
Ideally it would check the change in the published check box. But how to do this? The plug in would need to know the original state of the checkbox and compare with the new state.