hello,
I was wondering if it was possible to automatically set the pub_date to the createdon when creating a new document ? It could be quite useful when blogging to postdate posts !
-
MODX Staff
- 730 Posts
Are you entering blog posts from the manager, or from the front end? If front end, what snippet is creating the documents?
I’m using the manager to post but if it’s possible through newspublisher I’ll go with that !
-
MODX Staff
- 730 Posts
Sorry, I should have also asked, would you find that useful because you don’t want the actual date that you created the document on to show up on the front-end, you’d rather have the publish-on date to appear?
Well most of the time the default date is OK but if no default date is set the post shows up as in 1970 ... So basically it’s only for the very few times I need to postdate that I have to find a solution !
-
MODX Staff
- 730 Posts
Have you tried using the [*publishedon*] variable in your template? It should always contain a proper date (once a document is published).
Just tried it, it seems to give the first date where it was published. If you change the date after it isn’t updated.
Do you know where this portion of code is ? The easiest way in my case is just to update published date with the created date by default
-
MODX Staff
- 730 Posts
Sorry ripper, I’ve just become too confused about what you’re looking for. Help anyone?
I think it’s that ’pub_date’ is populated only when a certain publishing date & time is set. ’publishedon’ is set only when an article is published immediately (publishedon is probably more relevant than createdon).
In templates you can use PHx to choose the right variable, but that won’t work for sorting in Ditto.
I reckon pub_date should always be set; I wrote a plugin that updates the value of pub_date whenever a document is published. Happy to share it if it would be useful. Is that what you’re after, ripper?
Cheers
Matt
I think that’s what he is after indeed and so am I !
It would seem only logical that the pub_date is set to match createdon if none has been set, instead of being empty : no ?
I had already brought this up a few times, and thought the ManagerManager plugin could be a solution with the rules allowing to set default value but never got around to testing it...
.: COO - Commerce Guys - Community Driven Innovation :.
MODx est l'outil id