Blog Sections Open
Setting a Default Value for a Date TV in Evolution CMS
A guide to the common “current date by default” problem for Date TVs and why naïve @EVAL attempts often fail.
Setting a default value for a Date TV sounds simple until you discover that familiar @EVAL tricks do not always behave the way you expect in manager field initialization.
The common expectation
When a new document is created, the Date TV should already contain the current timestamp or current day.
Why the obvious attempts fail
@EVAL return time();
@EVAL $output = $modx->runSnippet('nowTime'); return $output;
Depending on the widget and the point where the default value is applied, the TV may ignore the dynamic expression or expect a different stored format than the visible UI suggests.
A safer approach
Instead of relying on one magical default expression, initialize the value deliberately at document creation time or through a manager-side event. That gives you full control over the format written into the TV.
What to keep in mind
- the TV widget format and the stored value format are not always identical
- a visible “date only” field may still store a datetime
- default logic is often more reliable in an event or helper than in a fragile inline binding
Passing Parameters into Chunks with parseChunk in Evolution CMS
A reusable parser pattern for avoiding dozens of one-off helper snippets when you only need to inject values into a chunk template.
Using a Resource List TV and Returning a Real Link Label
A TV configuration guide for choosing resources efficiently in the manager while still outputting a proper link label instead of only the numeric resource ID.