Views, Dates, and Arguments
This is work done in Drupal V6. Drupal is an Open-Source Content Management System. More information is available at http://drupal.org.
I needed to create a View for a Custom Content Type that took an optional date (year) as an argument. I followed the normal process for defining the various fields of a View. The argument was defined with my custom content value (field_event_season). The definition included creating a 'Summary, sorted ascending' action if no value was present. Since I wanted to display the entire list, this is the appropriate setting.
I saved the argument definition and got the error:
SELECT DISTINCT DATE_FORMAT(STR_TO_DATE( node_data_field_event_season.field_event_season_value, '%Y-%m-%dT%T'), '%Y') AS node_data_field_event_season_field_event_season_value, COUNT(node.nid) AS num_records FROM node node LEFT JOIN content_type_lasig_event node_data_field_event_public ON node.vid = node_data_field_event_public.vid WHERE (node.status <> 0) AND (node.type in ('lasig_event')) AND (node.nid != 2) AND ((node_data_field_event_public.field_event_public_value) = ('Yes')) GROUP BY node_data_field_event_season_field_event_season_value ORDER BY node_data_field_event_season_field_event_season_value ASC LIMIT 0, 15
in ***/sites/all/modules/views/includes/ view.inc on line 771.
It is not necessary to understand the SQL statement above to see the two important parts: "user warning: Unknown column" and "***/sites/all/modules/views/includes/view.inc on line 771". The first part is the problem. The second one indicates that it is in the Drupal system code. This means there is an error in something that I didn't write.
I am using Drupal V6.22, Date V6.x-2.7, and Views V6.x-2.12. There are a number of other modules installed, but these are the relevant ones for this discussion.
After a bit of researching I found an article on the Drupal site (http://drupal.org/node/284034) that describes the same problem. The posted solutions are:
- Downgrade the Date module to V6.x-2.6. This is reported to not have the problem, but there are features in V6.x-2.7 that are needed to Calendar.
- Upgrade to the 'dev' version (V6.x-2.x-dev). Of course, you are running a risk using a 'dev' module on a production site
It turns out that this error is present for any type of sub-setting of the available data (summary or default values).
As of the writing of this post, the team has not yet made a decision as to which option we are going to use. We are not running Calendar; however, we are concerned about giving up the bug fixes in V2.7. There is also a patch for this error; however, some people claim does not work.
We also ended up providing a default argument through PHP code (so it didn't need to be changed on a regular basis).
The attached file are the slides for a presentation on this topic.