All,
I have created a Content Type which includes a field of type Date. I would like to create a Views filter such that only those nodes whose date falls within the current month are selected. Can someone please show me how to accomplish this.
Thank you.
I did some more digging and believe that the best approach is to use PHP Views. I installed the module, wrote my 'challenging' code, but am not getting the expected results.
For debugging purposes, I created the following output field code:
<?php
$field_forumdate = $data->_field_data['nid']['entity']->field_forumdate['und']['0']['value'];
$forumdate=strtotime($field_forumdate);
$currdate=time();
$nc = date('n', $currdate);
$nf = date('n', $forumdate);
$tflag = 'false';
if ($nc == $nf) {
$tflag = 'true';
}
print 'Current month: ' . $nc . ', Forum month: ' . $nf . ', tflag: ' . $tflag;
?>
I created three Content types, and set the ForumDate fields to dates in October, November, and December. Looking at the preview, I see the following:
Current month: 12, Forum month: 12, tflag: true
Current month: 12, Forum month: 11, tflag: false
Current month: 12, Forum month: 10, tflag: false
Next, I created my filter code - which is identical to the above:
$field_forumdate = $data->_field_data['nid']['entity']->field_forumdate['und']['0']['value'];
$forumdate=strtotime($field_forumdate);
$currdate=time();
$nc = date('n', $currdate);
$nf = date('n', $forumdate);
if ($nc != $nf) {
return TRUE;
}
The problem is that all three nodes are still being returned, i.e., the filter does not seem to be filtering. Please help!