Topic: A Bit odd...  (Read 2057 times)

Pages: [1]   Go Down

#1: 3-Oct-2008, 09:45 PM


fruitwerks
Posts: 382

tacos are yummy!

I am using PHx at the moment, mostly for date manipulation. I have it installed and working, so I thought? I tested a few things with the simple stuff such as :ucase - on to the issues. I installed the ':timesince' modifier. That kills anything I try to use it on. This is true for even built-ins like pub_date. My biggest worry right now is this one.

Code:
[+birthday:date=`%m.%d.%Y`+]

That outputs 31.12.1969! And that happens with any date a I throw it. This is being called via Ditto, but cached or not, it does the same thing.

Any ideas?

#2: 4-Oct-2008, 06:00 AM

Testers

dev_cw
Posts: 4,179

WWW
That is the dafault time (as if it were balnk). Are you sure that phx is installed correctly? Seems like there is something that is not processing. Make sure that the correct events are set in the plug in manager, I think it only needs OnParseDocument. If that is correct then it may be a conflict with another script, in which case you need to  Edit Plugin Execution Order by Event.

Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

Something is happening here, but you don't know what it is.
Do you, Mr. Jones?  -  [bob dylan]

#3: 4-Oct-2008, 08:11 AM


fruitwerks
Posts: 382

tacos are yummy!

I double checked - I did everything 'by the book'. Is there a simple page I can make to test a few things? I enabled logging and the only thing I see that may be a problem is this...

Code:
12 [10:52:50] MODx / PHx placeholder variable: title
13 [10:52:50]   |--- Skipping - hasn't been set yet.

That is the closest to an error as I see. And I am not sure where that is from either.

#4: 5-Oct-2008, 10:56 PM

ryanlwh
Posts: 19

Are you sure birthday has the correct value? Have you tried to output birthday without phx modifiers?

#5: 6-Oct-2008, 12:44 AM

Coding Team

sottwell
Posts: 10,556

WWW
Keep in mind that most date formatting functions in PHP expect a timestamp to start with, while most date inputs in MODx (especially those that use the javascript calendar picker widget) create a date and time (usually in the form of mm-dd-yyyy h:m:s), so trying to use a formatting function on that will be trying to work with an invalid timestamp, thus causing the output of the default beginning of the Unix epoch in 1970 (or 12-31-1969).

To properly use the date formatting functions, a script first needs to use the strtotime() function, converting a date/time string to a Unix timestamp.
sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html

#6: 12-Dec-2008, 08:12 PM


fruitwerks
Posts: 382

tacos are yummy!

what would be the easiest way to do this? the time doesn't matter, only the date is what I need to work with.

#7: 13-Dec-2008, 05:55 AM

Testers

dev_cw
Posts: 4,179

WWW
This is how I would do it. In 096x I use utility snippets rather than PHx to avoid the extra plugin and possible conflicts. I love using PHx inside snippets tpl like ditto, maxigallery and jot.
Code:
<?php
// [[myDate? &date=`[*birthday*]`]]
// check input fields
$date = isset($date) ? $date "";
$format = isset($format) ? $format "%m.%d.%Y";

// only process the date if a value exists
if($date != ""){
$output strftime($date$format);
} else {
$output "";
}

return 
$output;

?>

Please note that the date TV needs to be unixtistamp for this to work.
Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

Something is happening here, but you don't know what it is.
Do you, Mr. Jones?  -  [bob dylan]
Pages: [1]   Go Up
0 Members and 1 Guest are viewing this topic.