Hi,

I've written a views query handler that pulls data from a web service call. There is a date field (i.e. uses views_handler_field_date to do render of the field) that seems to be treated correctly as a date field, that is I can change the formatter of the field for example and the field displays correctly. I would like to display my results using a calendar view but I it is not in the list available when I go the "Add view from template" screen. I suspect that I may have to do more to get Calendar to pick up my data, but I thought I would try and find out if what I'm doing is even possible.

Thanks,
Malks.

Comments

arlinsandbulte’s picture

The calendar templates likely only get field info from 'real' date fields.
You might be able to add a calendar view using a field that is listed and edit the view to work with your external date data.

malks’s picture

Hi, thanks for the reply. I think I get what you're saying... Having a quick look Calendar is looking at what entities are defined in the install and so even though my query plugin is returning date data it's not an entity per se, so I'm out of luck. I don't think your suggestion works as the base type of my data is not content/user data so the templates there wont be able to show my data.

KarenS’s picture

Status: Active » Fixed

If you have a custom table with a date field you can get it in a calendar but you have to do two things:

- Your field must have a Views filter that is based on the Views date filter. That involves adding Views integration for your table to implement at least a filter for your data.
- You have to implement hook_date_views_fields(). See an example of that in the Date Views module where Date Views does it on behalf of the core date fields like the node creation date.

If you do those two things the field should show up as an available date field that can be used to build a calendar.

No one has documented this process yet. Hopefully someone who is trying this will get some documentation written.

malks’s picture

Hi,

I had a quick look at the date views module and, if I'm getting it, I still need to define it as an entity don't I? Otherwise just defining in the form "table.field" won't work?

Thanks,
Malks.

malks’s picture

Status: Fixed » Active

I've looked at this a bit more and unless I'm missing something then the above recommendation won't work. The issue for my use case is that there is no base/custom table in this instance. The code in the Date Views module will only look for entities I believe? I tried creating an entity to wrap the whole thing in, but even with a few hacks to get it past, like saying that my entity is fieldable when it shouldn't be I still couldn't get this to work. Any help much appreciated, but if the recommendation is just that it won't work that's fine too.

Regards.

thekevinday’s picture

I have issues that sound exactly like what is mentioned in #5 here.

I did not want to hijack this thread so I created a separate bug report here: #1608518: Calendar based on non-node entity types produces WSOD and more ....

Properly solving that issue may lead to solving the problems mentioned here.

bneel’s picture

Don't forget to add more infos in the filter & argument handler hook_views_data(). The key 'is date' is critical if you want this to work.



    $data['fiche']['date_end']['title'] = t('Date end');
    $data['fiche']['date_end']['help'] = t("Date de fin à laquelle la tâche est affectée");
    $data['fiche']['date_end']['field']['handler'] = 'views_handler_field_date';
    $data['fiche']['date_end']['field']['click sortable'] = TRUE;
    // $data['fiche']['date_end']['filter']['handler'] = 'views_handler_times_date';
    $data['fiche']['date_end']['filter'] = array(
        'handler' => 'date_views_filter_handler',
        'empty field name' => t('Undated'),
        'is date' => TRUE,
            //'skip base' => $base_table,
    );


    $data['fiche']['date_end']['sort']['handler'] = 'views_handler_sort';
    $data['fiche']['date_end']['argument'] = array(
        'handler' => 'date_views_argument_handler',
        'empty field name' => t('Undated'),
        'is date' => TRUE,
            //'skip base' => $base_table,
    );

Have a look at http://api.drupalize.me/api/drupal/function/date_views_views_data/7
how the date_views_views_data is implemented.

Neslee Canil Pinto’s picture

Issue summary: View changes
Status: Active » Closed (outdated)