Event Views: Views 2 support
aaron - August 11, 2008 - 16:15
| Project: | Event Views |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
| Issue tags: | views2 event |
Description
this file needs to be renamed to event.views.inc. not sure how to make a patch with a new file; even the -upN option didn't work for me.
patch needs work; it's just a start (and doesn't seem to work right for even what it purports to do).
| Attachment | Size |
|---|---|
| event.views_.inc_.txt | 1.11 KB |

#1
subscribe
#2
Attached is my start on porting. To say it needs some serious work would be an understatement, as
Testing, thoughts & help would be greatly welcomed.
#3
Event views is its own project, moving over there.
#4
Deprecate Event Views.
I don't think it's necessary to continue to have a separate Event Views. The module would at its bare bones consist only of this:
<?php// $Id$
?>
with the obligatory event_views.info file and event_views.views.inc.
Seems simpler to just use event.views.inc and forgo having to enable a module that does nothing that Views 2 doesn't already do (as far as automatically including a properly named .inc file).
#5
How can I subscribe without needing to make a post?
#6
Currently trying the code from #3 as modules/event/events.views.inc, seems OK so far. I'm not using arguments but simple filtering and sorting is working.
#7
The patch (#3) doesn't work anymore with Views 6.x-2.0-rc2, in the Sort options of Views I get
Error: handler for event > event_start doesn't exist!"any idea how to correct this in the patch?
#8
Have you read about the API change in the release notes? Could this be where the rub is?
Cheers.
#9
Comparing, for example profiles.views.inc from rc1 and rc2 you can see that a lot was changed (reduced) from line 221
on now we have there
/*** Implementation of hook_views_handlers() to register all of the basic handlers
* views uses.
*/
function profile_views_handlers() {
replacing lots of code
I think something similar must be done at event.views.inc
#10
is this still being worked on or being squeezed out?
#11
I have not had a chance to work further on the ported include file I originally uploaded in #2, nor have I had a whole lot of feedback on it either. Note also that I am not the maintainer of this module, just trying to help out.
Views 2 6.x-2.0-rc2 was released long after I logged off last night. If you will have a bit of patience, I will try to track down the issue in the next few days. As always, constructive help and suggestions are welcome.
#12
merlinofchaos did post something on his blog about API changes - there's also a comment which might help.
#13
I'll preface this with a few caveats:
There are a few hoops to jump through for this version due to the API changes in Views.
Edit your event.module file, adding the following code at the bottom of the file:
/*** Implementation of hook_views_api().
*/
function event_views_api() {
return array(
'api' => 2,
'path' => drupal_get_path('module', 'event'),
);
}
These files are strictly to deal with the Views API changes in 6.x-2.0-rc2; I have not yet mucked about with the issues listed in post #2.
NB: Edited for clarity in response to posts #15 through #18.
#14
(#13) It works!!
I Use the event start_date field for sorting an everything looks fine.
Thank you for the help
#15
can u run this by me again please LOL
one and 2 confused me !! insert into folder or file?
#16
For (#15)
1. I inserted the folder (its new)
2. I inserted the file
#17
how did you guys get this to work with drupal 6,4?
#18
@cahsz
I am using Drupal 6.4:
I first installed the new versions of Views and cck and verifyed that they work (don't forget update.php).
After confirming that all is OK, except the event views, I deleted the event folder and replaced with an event folder
Version prepared as in #13 (don't install the offficial event views module!!).
Then I runned update.ph, cleared caches and that was it.
#19
i am sorry but that made absolutely NO sense
#20
This is cool. It worked for me. One thing I'm having problems with is filtering View items based on the start date. I'd like to use the "between" filter, where only events that are between the current date and some future date appear.
Thanks again.
#21
Woohoo! Method also works with:
Views 6.x-2.0-rc4
event HEAD
Thanks.
#22
I dig it! As of 09 October 2008 04:00 GMT, method also works with
views-6.x-2.0-rc5
event-6.x-2.x-dev
Talk about a lifesaver!
Thanks a million - hope we get a working event_views for 6.x someday...
#23
hi, I tried principessaDS's procedure and it works except I am having trouble with getting a view to work where it Lists the date (1st by years, then by months) that I can do easily in drupal 5.x
It is basically working except the Link Text for the links are blank, and therefore no links
I get:
* (138)
* (2)
and I should get
* 2008 (138)
* 2009 (2)
the source code of the page reveals the links are generated correctly (listed below), if I go to /event/2008, I get simular results, just a LI for each item and a count but no text to click on but source code reveals the links are correct). If someone can point me in the direction where this code is generated, I will be happy to try to fix myself.
Thanks in advance!!
<li class="2 last"><a href="/admin/build/views/clone/event_view">Clone</a></li>
</ul> </div>
<div class="view-content">
<div class="item-list">
<ul>
<li><a href="/events/"></a>
(132)
</li>
<li><a href="/events/2008"></a>
(2)
</li>
</ul>
</div>
#24
The bug in #23 occurs in function summary_name and function_title in event_handler_argument{month,day,year,fulldate}.inc . By commenting these functions out, I at least get text to the links (being the number of the day, month, year, etc).
#25
Hi. Could not make exposed filters to work (event start date and end dates).
What I found is that this patch is trying to compare values from the database with the values from exposed filter. The issue was that the DB values are stored in YYYY-MM-DD HH:SS format, while values in the exposed filters are converted into UNIX timestamp.
This change (to the file "event_handler_filter_date.inc") below make them working fine:
<?php
// $Id:
class event_handler_filter_date extends views_handler_filter_date {
function op_between($field) {
if ($this->operator == 'between') {
$a = intval(strtotime($this->value['min'], 0));
$b = intval(strtotime($this->value['max'], 0));
}
else {
$a = intval(strtotime($this->value['max'], 0));
$b = intval(strtotime($this->value['min'], 0));
}
if ($this->value['type'] == 'offset') {
$a = 'NOW()' . sprintf('%+d', $a); // keep sign
$b = 'NOW()' . sprintf('%+d', $b); // keep sign
}
// %s is safe here because strtotime scrubbed the input and we might
// have a string if using offset.
$this->query->add_where($this->options['group'], "UNIX_TIMESTAMP({$field}) >= %s", $a);
$this->query->add_where($this->options['group'], "UNIX_TIMESTAMP({$field}) <= %s", $b);
}
function op_simple($field) {
$value = intval(strtotime($this->value['value'], 0));
if ($this->value['type'] == 'offset') {
$value = 'NOW()' . sprintf('%+d', $value); // keep sign
}
$this->query->add_where($this->options['group'], "UNIX_TIMESTAMP({$field}) {$this->operator} '%s'", $value);
}
}
?>
Namely the chaged lines were:
$this->query->add_where($this->options['group'], "UNIX_TIMESTAMP({$field}) >= %s", $a);
$this->query->add_where($this->options['group'], "UNIX_TIMESTAMP({$field}) <= %s", $b);
and
$this->query->add_where($this->options['group'], "UNIX_TIMESTAMP({$field}) {$this->operator} '%s'", $value);
all $field variables are now prefixed with UNIX_TIMESTAMP() function.
This works with Views 2.0 and Drupal 6.5.
#26
i couldn't get the filters to work to show only current or upcoming events... it would show all events, no matter what i put in the filter.
Basically trying to replicate the functionality of the upcoming events block which comes with events module--however, trying to add extra functionality by showing only events that under a specific taxanomy, for instance.... current block shows all upcoming events, no way of filtering.
#27
Works in everyway, except filters.
(tested on postgresl 8.3 + php5-cgi + lighttpd)
Perhaps this can be made an issue on the events project, and get the fully working parts into the events module, and then deal with filters seperately
#28
OK this doesn't need to be included in the event module it can stay as a seperate module. The events views module simply needs to have the hooks_views_api included within it. The includes can then live with that sub directory and the code can be developed out with the main events module. I'm sure Killes split the code out for a reason. And if he wants a co-mainter for this module I'm more than willing to take on the role ;-)
#29
#13 Still working in the most part for me (although I'm not doing anything too complex) - I guess what we need is a patch for #13 against the last 6.x-2.x-dev release for review.
#30
Seems to work pretty well after basic testing.
#31
It looks like the issue with the filter is doing a typecast from datetime to integer when adding the seconds to the date.
event.event_start NOW()+864002008-12-20 20:22:00 20081217241302.000000
Instead mysql or postgresql's date operators need to be used, or do it in php (most likely scenario as dates are pretty different in mysql and postgresql). Though I can't remember if postgresql is supported in event at all.
postgresql: now() + interval '1 day'
mysql: date_add(now(),interval 1 day)
In my implementation of event_views from august (http://drupal.org/node/342129#comment-1137911) I did things in php. Note that code is radically different from this module.
I used php 5's new date functionality reluctantly. For instance,
$date = new DateTime("2006-12-12");$date->modify("+1 day");
echo $date->format("Y-m-d");
#32
subscribe
#33
In case it's helpful to the maintainers: The code in #25 did not solve the time problem for me, date values displayed "12/31/1969 - 16:33". I doubled checked caches and such. Thanks for your efforts folks! (using d6.8, event 6.x-2.x-dev)
#34
I agree, since #13 does not work for me using Drupal 6.8 and Event 6.x-2.x-dev. (Had no expectations, but it was fun to try. ;p )
#35
#13 still working for me with Drupal 6.8 and event 6.x-2.x-dev Version from Dec. 28. (I only use a start date filter)
#36
#13 is not working on Drupal 6.9, Event 6.x-2.x-dev (2009-Jan-02) & Views 6.x-2.2
I got "Error: handler for event > event_start doesn't exist!"
#37
I agree with comment #36.
I get Event views is not compatible with this version of Drupal which is 6.9
#38
#13 still working for me with Drupal 6.9 and event 6.x-2.x-dev Version from Jan. 26. (I only use a start date filter)
At #36-#37, did you copy the directory includes and the file event.views.inc to the event directory, and modified event.module as stated in #13?
#39
Verified that this works with the Views 6.x-2.2
#40
subscribe
#41
subscribe, we need this module. thanx.
#42
Let me know if I can be of service to this update; we need this module too.
#43
subscribe
#44
Subscribe
#45
subscribing
#46
Sorry for this question, but is anyone actually working on this? We are using Event module for a long time, at the same time we've been waiting for the Views integration. Without Event + Views we can't move forward.
#47
Who knows what the status of the module is since killes hasn't commented on anything here for months.
It could be deprecated and the code put back into event as the main patch above does. Or it could still live on its own as its own module. I went ahead and coded my own version of event views to my own liking because it was actually easier than porting the 5.x for that project (time/budget constraints). It's actually pretty easy to hack out basic views support, I think it took me 4-5 hours.
At this point it probably won't get resolved until there's an actual release of the event module for 6.x (I've been using devel successfully since Q3 2008).
http://drupal.org/project/issues/event?status=Open&priorities=All&catego...
#48
Subscribe
#49
#13 still working with drupal 6.10 and event 6.x-2.x-dev (26 March Version) -
That patch should be included in the actual dev. event version in order to have an event Version with included Views 2 support.
#50
Quoted from an email from Gerhard Killesreiter :
hope that helps.
#51
subscribe
#52
I'd just assumed that this would be here so I could create a custom calendar block.
subscribe
#53
I've been following this issue for a while, and I'm wondering if maybe someone should state the obvious here. From what I've seen, it seems like Event is mostly being maintained for legacy users while most forward development seems to be coming from the cck + views + calendar side.
If you can demonstrate otherwise, please speak up?
I ended up doing a conversion from the 6.x version of Event to the 6.x version of CCK + views + calendar. I used this page from PingVision to get me started, though that script was not what I ended up using. I am hesitant to post my copy of the script until I could have someone help me test it -- if you are interested, have a site you can play with, and are comfortable with editing PHP/mySQL statements, contact me privately through this site and we'll give it a go.
Major caveat: Please note that I have no knowledge of how repeating events worked under Event, and I have zero idea if this script could be used for repeating events under Event.
The end result of my script was pretty seamless for us. I took the existing 'event' nodes, added on a CCK field for the new start time, used the script to generate the date fields in the format that CCK expects, and then inserted those fields into the database. I then created new versions of my views, blocks, and pages doing sorts based off of the CCK date fields, and once I had those matching the old versions, I turned off the Event module.
Again - if you're interested, comfortable with script hacking, and can be patient with someone who is carrying a massive work overload, contact me. Maybe we can get something going that will solve the long-term needs of the people in this thread.
#54
Hi,
I had been wondering about how important events are when views can do much the same thing but OG Calendar seems to rely on it which the customer wants - but maybe the results of OG Calendar can be achieved using views 2 anyway?
#55
Subscribe
#56
I am trying to edit date_browser view of calendar style.
There is not events date arguments (like event start date ...) in section "Date field(s):" of argument "date".
When I trying to make my own argument and select "Event:Start date", then I read:
* The calendar_style style requires a Date argument.
* The Date browser style requires the Date: Date argument.
Where am I wrong?
#57
sorry.
#58
I've noticed this module and hoped I could use it. But apparently it didn't work for me (drupal 6.10), are there changes in the views2 api since this module was written?
Anyway, based upon another views implementation, I added some primitive functionality for what I needed: Managing the start & end date.
This is based upon the existing views classes, this means that the existing date functionality from views remains the same.
1. Add the following code to the event.module:
/*** Implementation of hook_views_api().
*/
function event_views_api() {
return array(
'api' => 2,
);
}
2. Place the attached files in your event module. Remove the .txt extension!
3. List your modules under /admin/build/modules (in order to let the system detect the newly added files & detect the views hook)
#59
#13 worked a treat for me using Views 6.2.5 and Event 6.x-2.x-dev, thanks.
#60
#61
Thank you so much, definitely works in every way ..
#62
Is this now committed to the dev trunk?
#63
I was about to add it to CVS but it looks a bit incomplete. Can somebody post a view that was created with this?
#64
#58 - works great!
#65
changing status
#66
Has anyone who has gotten this to work got it to work with Drupal 6.13 core?
#67
I was not able to get #58 to work with Drupal 6.12. I guess I'll work on migrating my data to CCK instead. A note explaining that the module is no longer being maintained would seem appropriate....
#68
On upgrading from Drupal 5 to Dupal 6.13, I am getting 'broken/missing handler' for 'event_start' and 'event_end' fields when trying to convert my views1 to views2. I would like to filter nodes on this important data, and wonder if you or other developers are working on a solution, or if I need to abandon such hope and mirror this information to CCK date fields (Date API). #58 fix did not work.
That is, what can I do to make this fix a priority?
#69
For the record, I abandoned hope and converted my event dates to cck.
I used the cck date module and date api. I created a cck field called eventstart. I used "now" as the default from and to dates. I used "date" as the format.
I then used this code to convert all the event dates to the cck eventstart field:
<?php
// You backed up your database, right?
// Set up the mysql connection
// Drupal's bootstrap function may be substituted here
// require_once '/path/to/drupal/includes/bootstrap.inc';
// drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$con = mysql_connect('localhost', '<your db username>', '<your db password>');
$count = 0;
mysql_select_db('<your db name>', $con);
// Cycle through all the records in the event table
$q = 'select * from event';
$r = mysql_query($q);
while ($row = mysql_fetch_assoc($r)){
// Transform the date information
// CCK date format: 2008-12-10T00:00:00
// event date format: 2006-11-13 15:00:00
$startdate = preg_replace ("/ /", 'T', $row['event_start']);
$enddate = preg_replace("/ /", 'T', $row['event_end']);
$nid = $row['nid'];
$node = node_load($nid);
$vid = $node->vid;
$count++;
$timezone = 'America/Los_Angeles';
$node->field_eventstart[0]['value'] = $startdate;
$node->field_eventstart[0]['value2'] = $enddate;
$node->field_eventstart[0]['timezone'] = $timezone;
$node->field_eventstart[0]['timezone'] = $timezone;
$node->field_eventstart[0]['timezone_db'] = $timezone;
$node->field_eventstart[0]['date_type'] = 'date';
$node = node_submit($node);
node_save($node);
}
print "<br>".$count." records converted.";
?>
You may have to change the $timezone, but otherwise, should work. Note that you use the "event" content type for this new "eventstart" field, you will have to modify your existing views to replace the event.module "event_start" field with cck "eventstart".
#70
It works with:
Drupal 6.13
Views 6.x-2.6
Event 6.x-2.x-dev (2009-Mar-16) example: http://openwaterswimming.eu
doesn't work with:
Event 6.x-2.x-dev (2009-Jul-05) example: http://noww.nl
both sites use all the same modules. Only the event dev. is different.
#71
#58 worked like a charm, events dev from Aug 29...Views2 6.x-2.6
#72
Now #58 works for me also.
Drupal 6.13
Events dev from Aug 29
Views2 6.x-2.6
Still would like the choice between days or date in the upcoming event block included
issue http://drupal.org/node/78271
#73
subscribe
#74
I just want to give a shoutout to SomebodySysop on #69. Brilliant! This is obviously an updated version of this code (which does NOT work).
Just wanted to say thanks...
I'd recommend putting your solution somewhere that Google and Drupal search can find it!I took the liberty of archiving it for others here. It's gold for people who want to make the switch. Thanks!#75
I am running:
Drupal 6.14
Event 6.x-2.x-dev (2009-Aug-28)
Event Views 6.x-2.x-dev (2009-Jun-28)
Views 6.x-2.6
Observed the reported Error: handler for event > event_start doesn't exist!" when trying to convert my Views1 views.
I added the snippet and files suggested by #58 (Many thanks).
Disabled the Event Views module.
Disabled and re-enabled the event module and ran update.php.
Views1 views converted to Views2 and could be edited as expected.
Needed to reset the event start time fields in the views editor.
The live preview showed the correct information to be displayed as a block view.
The block views showed on the designated pages as desired.
#76
Is the original issue still a problem or can we close this issue?
#77
Yes because it still isn't an integrated part of the module but a patch.
After every new release one have to add the code from #13 and hope that the patch still works.
#78
#58 works for me!
Thanks a lot.
I think this must be a priority and has to be bundled as a contribution to de Event module.
Start Date is the most important field while filtering events, i think, and I can't get it without this solution.