Hey ppl, as always, thank you for the great module!
Here's a little something that may be interesting to some of us:
Custom date field support!
e.g: I have a custom declared field within any module:
$my_table["date_field"] = array(
'group' => $my_view_info['group'],
'title' => t(' a date. '),
'title short' => t(' date. '),
'help' => t(' date. '),
'field' => array(
'field_name' => 'a date',
'type' => 'datetime',
'tz_handling' => 'none',
'table' => 'my_table',
'handler' => 'my_date_handler',
),
'argument' => array(
'table' => 'my_table',
'handler' => 'views_handler_argument_date',
),
'filter' => array(
'table' => 'my_table',
'handler' => 'views_handler_filter_date',
),
);
// Add an alias to prevent conflicts
$data['my_table'.'_' . 'date_field'] = $my_table;
Now, as some may know, the Field module won't detect this as a real field, since it wasn't declared within the normal mechanics of Drupal.
My solution is this small patch that helps calendar_plugin_row.inc detect and use these custom fields (without causing any other disturbance, of course)
You may want to look into my other issue within the date module, since they're linked and one would need the date's patch to make this work.
http://drupal.org/node/1485794
Tell me what you think, is this a good approach? Is there something missing?
I know that this is fairly hard to test, but I'm sure it's worth it! Thx alot to everyone helping me out
Comment | File | Size | Author |
---|---|---|---|
#1 | 1485956-1_Calendar_m-a.patch | 2.24 KB | Marc-Antoine |
custom_field_m-a.patch | 2.12 KB | Marc-Antoine | |
Comments
Comment #1
Marc-Antoine CreditAttribution: Marc-Antoine commentedImproved the patch a bit; Now cropping the field's alias when exceeding 60 char (same as Drupal's way of dealing with field's alias)
Comment #2
johnvNice. Can you make this also work for creating a view from a template?
See the patch for calendar.views_template.inc in #1466698: Cannot create View (from template) for Entities with Fields using Fields API
Comment #2.0
johnvadded some bold and clarification
Comment #3
Neslee Canil Pinto