Adding a Date Filter to Views When Using Custom Fields
Submitted by benjy on Friday, May 24, 2013 - 18:15.
I recently exposed some custom database tables to views using hook_views_data() which as usual was a pleasant experience, until I wanted to use the date filter that the Date module provides. This isn't creating a filter on your field, it's the field in the list that looks like Date (node). The word "node" in brackets is referring to the base table that will be used for the date filter, this allows you to compare multiple dates from the same table. So the hook you're looking for: hook_date_views_extra_tables(). It took me about 2hrs to find out so I hope this saves someone else sometime.
An Example
/*
* Implements hook_date_views_extra_tables().
*/
function MODULE_date_views_extra_tables() {
return array($base_table="base_table", $entity_name="entity_name");
}
Comments
[…] This entry was posted in Wordpress by Ben. Bookmark the permalink. […]
Add new comment