First off, I’m a noob to both MODx and PHP, so apologies in advance if this is an obvious question:
When including a [*pub_date*] call in a document, how do you format the output?
The beginners documentation says:
pub_date - Date the document is to be published. This is not a "normal" date, and must be processed by a script for meaningful output. Example:
strftime("%d/%m/%y %H:%M:%S", $value)
I understand strftime formatting, but how do I apply this value to the [*pub_date*] tag? It’s not specified anywhere for the PHP challenged.
Any help is much appreciated, thanks!
-
MODX Staff
- 730 Posts
You’re passing the literal string "pub_date" to the snippet, instead of the value you want.
Try this:
[[DateTime? &format=`%B %d, %Y` ×tamp=`[*pub_date*]`]]
Thanks for the suggestion, unfortunately I’m still getting the same output.
Use non-cached form [!...!].
Sweet, that did the trick. Thanks all!
I think that the best way to format any of output data is
PHx. Different modifiers, logical conditions and other stuff.
In your case: [*pub_date:date=`%B %d, %Y`*]
No need to use dozens of different snippets. In future 0.9.7. it will be a part of MODx core.
DirectResize 0.9 beta. PHPThumb, sets of configurations, configuration, binded to specific path. No backward compatibility. |
DirectResize 0.9. PHPThumb, наборы параметров, параметры, привязанные к определенным путям. Без обратной совместимости.
Unfortunately, DirectResize project is closed. If you want to continue development, PM me for access to project page on Google Code. К сожалению, проект DirectResize закрыт. Если вы желаете продолжить разработки, обращайтесь через ПМ для получения доступа к репозиторию на Google Code.
[PLUGIN] DirectResize - as Maxigallery but for single images ::
Download :: [url=
http://modxcms.com/forums/index.php/topic,21490]
I am using what is recommended above:
[!DateTime? &format=`%B %d, %Y` ×tamp=`[*pub_date*]`!]
but the only date that is returned is Dec. 31, 1969.
Any suggestions? Thanks
Sorry, I figured it out. My document did not have the pub_date set. Now it does and all is well.