Can I select the input format in the rewrite field output? I need to include some jquery and have some of the values in a fews field be used in my jquery. The problem with that is I believe it wraps each field in a span so it would have to use the raw text data. I am trying to get a date from a node's event date field and use the date in a jquery countdown script. Here is the code (the tokens are not right but you get the idea:
<script language="javascript" type="text/javascript">
jQuery(document).ready(function() {
$('#countdown_dashboard').countDown({
targetDate: {
'day': [day],
'month': [month],
'year': [year],
'hour': [hour],
'min': [minute],
'sec': [second],
},
'omitWeeks': true
});
});
</script>
So then I had the idea of adding a PHP Customfield to achieve this, adding this code to it:
<?php
$full_date = $data->node_data_field_event_date_field_event_date_value;
print_r($full_date);
$second = substr($full_date, -2, 2);
$minute = substr($full_date, -5, 2);
$hour = substr($full_date, -8, 2);
$day = substr($full_date, -11, 2);
$month = substr($full_date, -14, 2);
$year = substr($full_date, -19, 4);
echo "<script language=\"javascript\" type=\"text/javascript\">
jQuery(document).ready(function() {
$('#countdown_dashboard').countDown({
targetDate: {
'day': $day,
'month': $month,
'year': $year,
'hour': $hour,
'min': $minute,
'sec': $second,
},
'omitWeeks': true
});
});
</script>
";
?>
The problem is, for some reason, when I print out $full_date which is equal to '$data->node_data_field_event_date_field_event_date_value', it returns 2010-10-09 00:00:00 when it should return 2010-10-08 00:19:00. It's a day ahead and has no time. When I add the same field to views, I get the correct date and time, which is very odd.
Does anyone have any ideas on how I might solve this? I have been working on this for two days no and cannot seem to find a solution.
Thanks!
(oh, and I have already posted an issue similar to this in the Customfield module's issue queue but I didn't think that was the appropriate place for this.)
Comments
Comment #1
dawehnerNo you cannot. The output of this field is html which is runned trough filter_xss_admin. So not every tag is allowed.
Alternative you can use theming or the module views custom field.
Comment #2
acondiff commentedread further down in my original post. I did use a PHP customfield but I ran into a problem. Do you know of a workaround?
Comment #3
dawehnerI suggest you to go to the customfield maintainers.
Comment #4
iantresman commentedFor reference, this is the Views Custom Field module, which ".. provides some useful (views)fields. [..] allows usage of custom text and the input filter system [..] that allows usage of custom PHP code (with access to view's database result)"
Comment #5
elektrorl commentedHey acondiff,
I don't think people understand your problem, but I have exactly the same problem. Did you find a solution?
Comment #6
bomarmonk commentedSame problem: dates processed through custom views fields (via php) are ahead one day. Still looking for a solution. As a side note, I think this problem only occurs with date fields that have date repeat turned on/enabled.
Comment #7
bomarmonk commentedThis might help: http://www.leveltendesign.com/blog/dustin-currie/format-dates-drupal