-
MODX Staff
- 2,502 Posts
I have a call working on my site that uses a TV date for an event date called
event_date. It is working fine except in the cases of documents that have the event_date TV unset. It is displaying the unixtime offset time where don’t want it to display at all.
I think I may need to create a filter or add some sort of @Eval to the TV to make this stop. Please see what I refer to in the attached image.
I am running:
Windows XAMPP
PHP 5.2.1
Apache/2.2.4
MODx 0.9.6
Ditto 2.0.3
Any help would be appreciated
Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup
magician.
Blog ✦
Twitter ✦
LinkedIn ✦
GitHub
Might not be the most elegant solution, but I have been using PHx to do just that and it works fine, provided you have a default value for the TV set.
Example (simplified styling for image for better readability) :
[tt][+phx:if=`[*photo*]`:isnot=`blank`:then=`<img src="[*photo*]" height="180" width="250" />`:else=` `+][/tt]
The default value for the TV is "blank".
The idea is to not show any image when none are uploaded.
Of course I didn’t use any widget for formatting as it gives me less control over styling, otherwise I would have just used a widget and wouldn’t need this PHx call.
For dates, if you’re using a widget to format the output, you could use "If no value, use current date" to No but I don’t remember using it and if it outputs anything at all (?)...
.: COO - Commerce Guys - Community Driven Innovation :.
MODx est l'outil id
-
MODX Staff
- 2,502 Posts
Yay!
Thanks Mr. M. for pointing me in the right direction. I have made it work with the following call in my Ditto Template Chunk:
[+phx:if=`[+event_date+]`:isnot=``:then=`[+event_date:date=`%A, %B %d at %I:%M %p`+]`:else=` `+]
In context it looks like:
<div class="ditto_item" id="ditto_item_[+id+]">
<h3 class="ditto_pageTitle"><a href="[~[+id+]~]">[+pagetitle+]</a></h3>
<div class="ditto_documentInfo">[+phx:if=`[+event_date+]`:isnot=``:then=`[+event_date:date=`%A, %B %d at %I:%M %p`+]`:else=` `+]</div>
<div class="ditto_introText">[+introtext+]</div>
</div>
The problem is that the date formatting takes the empty TV field and makes it the unixtime start time of Jan, 1, 1970 (although in my case it made it Dec, 31, 1969 because of the -4 hours GMT my box is. )
Thanks again and I hope this helps.
Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup
magician.
Blog ✦
Twitter ✦
LinkedIn ✦
GitHub