Views2 Integration

idontknowtheanswer - November 17, 2008 - 19:09
Project:Activity
Version:6.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:sirkitree
Status:closed
Issue tags:activity-6.x-1-3
Description

I've created a couple of blocks using using the Activity module to show recent comments on a users articles and recent comments\articles that a user has created. At the moment though I can't see any way of creating these blocks without having to make calls directly into the module itself. Should there be an include file that exposes handy core functions like "activity_get_activity", "activity_token_*" etc?

It's my understanding of Drupal that external APIs that are intended to be called should be in the include file (is that correct?), I'm a bit nervous calling the module functions directly as I guess they can be changed at will.

Hope I've not missed the point!

#1

sirkitree - December 8, 2008 - 08:06
Title:Include File?» Views2 Integration
Category:support request» task
Assigned to:Anonymous» sirkitree

You've not missed the point at all. I actually plan on getting some Views2 integration into activity within the next month or two here and that will take care of a lot of problems I believe, specifically this one :) Hence I might as well use this issue! Changing Category and Title, assigning to myself.

#2

timmillwood - January 13, 2009 - 21:09

This would be great to see.

(Subscribing)

#3

andreiashu - February 17, 2009 - 01:19

nice ! subscribing

#4

mradcliffe - February 17, 2009 - 16:24
Status:active» needs review

Please review this package based on DRUPAL-6--1 branch. Extract in activity/ module directory patch activity.module from cvs.

There are a couple of handlers to handle the target_role, module, and data fields. There's a basic default view comparable to the All Activity page.

The serialized $data just gets output as a link to whatever kind of object it was (node, comment, user). This should catch all of the contrib modules, but if there are any others, then it'll dump the serialized data (for testing). The output is probably not desirable, and more options are required in case someone wants to display node->teaser or some other kind of object. This also checks to make sure the node/user/comment exists before linking to a non-existent path (it just prints out the id which again is probably not desirable).

This is a work-in-progress, not complete functionality. Hopefully this gets the ball rolling to churn around ideas about how things should look and what needs to be added.

AttachmentSize
activity_views.tar_.gz 3.35 KB

#5

sirkitree - February 17, 2009 - 17:30

Awesome! Thank you mradcliffe! I look forward to reviewing this soon!

#5

jcmarco - February 18, 2009 - 18:25

Wow!! It works great!!

I would appreciate a lot having the comment:insert field with the tokens already applied, this way it would be possible to show exactly the same texts that are now in the existing module pages and blocks. The only issue would be for selecting which one from the different role configurations. Maybe it could be done with the activity:role field as a display option for the comment:insert field or using a filter in the view with the activity:role.
(We need to be careful using the right access permissions to show only the right information depending of user roles or role permissions)

I have tested it with the Spy Views from Views Bonus Module and it has a nice scrolling effect, I guess that it can be used as well with the ticker or carousel views modules.

Very nice!

#6

mradcliffe - February 19, 2009 - 15:28
Status:needs review» needs work

Yes this is what's left to do besides tidying things up.

It looks like you can do this in either pre_render() or render().

I'm having trouble formatting things correctly so that I can run activity_token_replace(). The $row array needs to be built properly. So far I have it replacing some tokens, but not all of them trying to step through the token replacement in activity manually.

Also we need to make sure that the case where a user has not included the correct fields is taken care of. If a user decides not to include module, created, operation, type, and target_role, then you won't be able to do token replacement because there is no data for it to replace! It would be pretty ugly to do another query to get that info. even though there are some view handlers that do extra queries in odd places in the views api.

#7

mradcliffe - February 19, 2009 - 20:43

I figured out what I needed from the previous post though I'm not able to use activity_replace_token(), but doing something similar.

I included the alternate serial output in case a user doesn't use the required fields. The code is a bit ugly and needs cleaned up.

For the role I'm using an option form in the serial field for now.

AttachmentSize
activity_views.tar_.gz 3.65 KB

#8

jcmarco - February 23, 2009 - 15:41

Hi mradcliffe,
I was testing your second patch, and although it works fine, it is not really very useful with the data serial field, it is not possible to process the information directly from views without coding. First patch was better. Thank you.

#9

Flying Drupalist - March 4, 2009 - 17:09

Testing this too

#10

mradcliffe - March 5, 2009 - 15:19

You probably don't want to use the default view, it needs to be redone. Please create your own view to test.

#11

JohnNoc - March 6, 2009 - 02:29

Looking forward to this being committed :-) Subscribing

#12

Flying Drupalist - March 10, 2009 - 23:47

This needs a tokenized text field rather than just the info output.

Also getting these errors:

* user warning: Unknown column 'activity_targets.uid' in 'on clause' query: SELECT COUNT(*) FROM (SELECT activity.aid AS aid FROM test_activity activity LEFT JOIN test_activity_targets activity_targets ON activity.aid = activity_targets.aid LEFT JOIN test_users users_activity_targets ON activity_targets.uid = users_activity_targets.uid LEFT JOIN test_users users_activity ON activity.uid = users_activity.uid ) count_alias in C:\xampp\htdocs\drupal\sites\all\modules\views\includes\view.inc on line 705.
* user warning: Unknown column 'activity_targets.uid' in 'on clause' query: SELECT activity.aid AS aid, users_activity_targets.name AS users_activity_targets_name, users_activity_targets.uid AS users_activity_targets_uid, activity.created AS activity_created, activity.data AS activity_data, activity.module AS activity_module, activity.operation AS activity_operation, activity.type AS activity_type FROM test_activity activity LEFT JOIN test_activity_targets activity_targets ON activity.aid = activity_targets.aid LEFT JOIN test_users users_activity_targets ON activity_targets.uid = users_activity_targets.uid LEFT JOIN test_users users_activity ON activity.uid = users_activity.uid LIMIT 0, 25 in C:\xampp\htdocs\drupal\sites\all\modules\views\includes\view.inc on line 731.

#13

mradcliffe - March 15, 2009 - 02:37

Since this seems to be kind of tabled into 6.2 I'm going to switch over and work on that instead.

One thing I noticed about the activity 6.2 views integration is that it's missing a couple of things that might help make the activity stream. Having 'type' and/or 'op' as fields will enable you to use them as grouping fields (and thus group the similar activity types on the same row as discussed at the BoF). Also should provide a relationship to the users table for 'uid' (doer) that way you can put things like user profile pictures and other user information. Again helps with the activity stream/facebook-style messages.

#14

Apollo610 - March 20, 2009 - 12:42

Definitely interested in Views2 integration (either activity branch)... subscribing.

#15

stella - April 9, 2009 - 12:44
Status:needs work» needs review

Here's another version of the patch. It's rolled against the latest 6.x-1.x-dev version and includes a new 'Row style' called 'Activity'. This will print the activity message generated from the serialized data column.

I know work on the 6.x-2.x branch is happening, but there's no upgrade path and I imagine it isn't that stable yet, so I'd still like to see this patch committed if possible.

Cheers,
Stella

AttachmentSize
activity_335498.patch 19.35 KB

#16

Liliplanet - April 9, 2009 - 12:46

subscribe, thx!

#17

stella - April 15, 2009 - 21:58

New version, with new filters for activity operation and type.

AttachmentSize
activity_335498.patch 20.95 KB

#18

Junro - April 16, 2009 - 13:16

subscribe

#19

sirkitree - April 27, 2009 - 00:19

tagging for next point release.

#20

sirkitree - April 27, 2009 - 01:06
Status:needs review» needs work

Stella, your patch applies cleanly enough, however I'm not seeing the row style plugin so the data field is just being rendered serialized. I know you have a couple of // FIXME:'s in here, so what am I missing?
Edit view all_activity | activity
All Activity | activity

I really want to get this in, so any feedback would be greatly appreciated.

#21

jaydub - April 27, 2009 - 02:10

retagging for next release

#22

stella - April 27, 2009 - 10:38
Status:needs work» needs review

In order to see the row style plugin, you must first create a view of the "activity" type (rather than node, user, taxonomy, etc). See the first image - 'add_view.png'.




Once you do that the activity row style plugin is available - see 'set_row_style.png'.

AttachmentSize
add_view.png 90.1 KB
set_row_style.png 93.38 KB

#23

mradcliffe - April 27, 2009 - 13:42
Status:needs review» needs work

I think those FIXME notes are from me, from activity_views_handler_field_serial.inc.

Edit: In fact ignore everything in this post except that comment above.

VVVVV Ignore that patch, it's bad.... crap.

AttachmentSize
activity.views_.patch 21 KB

#24

mradcliffe - April 27, 2009 - 13:48
Status:needs work» needs review

Okay, I tested and the patch works for me.

I have re-arranged things in the following patch as well as fixing an issue with the serial handler.

Sorry for the false edit above.

AttachmentSize
activity.views_.patch 18.03 KB

#25

sirkitree - April 27, 2009 - 16:19

Oh ok, I was going by the default view that is provided in this patch which I assumed already had Activity as it's base table, described in the first screenshot of #22

#26

stella - April 27, 2009 - 16:44

Last patch omitted the default view for activity items, so have added this back in.

Cheers,
Stella

AttachmentSize
activity_335498.patch 21.91 KB

#27

mradcliffe - April 27, 2009 - 16:50

I removed the default view because it may be better to use the row style instead of the serial field hack in a default view. It's kind of confusing at the moment. I kind of threw it in there just for testing purposes.

Probably need 2-3 default views to correspond with the activity pages already defined (activity activity/my or whatever it is now).

#28

stella - April 27, 2009 - 16:57

Yeah, the default view provided uses the table layout and just displays each of the columns in the db. I agree it might be better to switch to the 'unformatted' layout and use the 'activity' row style rather than 'fields' instead, so I've attached another version of the patch that does this.

AttachmentSize
activity_335498.patch 21.14 KB

#29

sirkitree - April 27, 2009 - 18:22

Looking good guys! I added a little error checking to _filter_type.inc and _filter_operation.inc mainly because hook_activity_info() has changed between versions (6.x-1 and 6.x-2) and if the 'op' or 'type' key isn't returned by hook_activity_info() we end up with errors when adding those filters.

The default view that stella rolled in is good to go - thank you.

However, I have a feeling that there are going to be people who really want to be able to use fields in order to customize their display, and it doesn't seem that _field_serial.inc is quite working yet, evidenced by the fact that when I did change the style from Unformatted to Table, my display looks like this:
Edit view all_activity | activity

I fixed this by simply resaving the data field so that it contained the $this->options['target_role'] variable, however the code style in that file was not satisfactory either (mainly the if else's). I formatted it with normal Drupal coding standards.

Also, can one of you verify what this piece within activity_views_plugin_row_activity_view.inc (commented out) is and remove it if we really don't need it?

<?php
    
/*
    if ($view->query === NULL) {
      return;
    }

    // Clear the fields first
    //$view->query->clear_fields();
    $view->query->add_field('activity', 'aid', 'aid');
    $view->query->add_field('activity', 'uid', 'uid');
    $view->query->add_field('activity', 'module', 'module');
    $view->query->add_field('activity', 'type', 'type');
    $view->query->add_field('activity', 'operation', 'operation');
    $view->query->add_field('activity', 'created', 'created');
    $view->query->add_field('activity', 'data', 'data');
    //$view->query->add_field('activity', 'nid', 'nid');
    */
?>

Please try my reroll to make sure that it's still performing as you've intended.

Thanks! Pretty excited to get this committed :)

AttachmentSize
activity_views.patch 22.83 KB

#30

stella - April 27, 2009 - 18:31

Yep, it still works as expected. :)

The commented out code isn't needed - I think it was something I was testing when adding the row style plugin, and it should have been removed before creating the patch, my bad.

#31

sirkitree - April 28, 2009 - 16:38
Status:needs review» fixed

Alright guys, it's landed! Thanks for all your help getting this in!
http://drupal.org/cvs?commit=204306

#32

mradcliffe - April 28, 2009 - 17:16

I added a documentation child page for this as it may be confusing -- http://drupal.org/node/447536. There is a spot for Activity 2.x views documentation as well.

#33

sirkitree - April 28, 2009 - 17:21

Awesome! Thanks mradcliffe!

#34

mikestefff - May 8, 2009 - 06:39

I probably sound like a lazy idiot, but how do we get the updated module with views support??

#35

stella - May 8, 2009 - 08:29

download the latest 6.x-1.x-dev version

#36

stanford - May 17, 2009 - 23:33

I've downloaded and enabled the dev version but when I create a new View of the Activity type, I only see "Fields" for Row Style. I do not see "Activity" as in screen shot from post #22.

#37

rjbrown99 - May 18, 2009 - 21:37

Add me as a person referenced from post #29 that would like to control all of the fields manually.

One of the things I am looking to do is to integrate the view with both user relationships and content profile. I.E. I'd like to add views relationships and fields so I can customize the output based on the content profile of each user in the activity action, and then have something like"[mycckfirstnamefield] [myccklastnamefield] is now following [mycckfirstnamefield] [myccklastnamefield]" where they are all linked back to the content/node profile. I could also use this to pull in other cck profile fields, like the user's picture.

Thanks in advance for the work everyone has done on this so far!

#38

System Message - June 1, 2009 - 21:40
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

#39

MGParisi - June 8, 2009 - 18:40
Status:closed» fixed

Is this a separate module, if so is there a module page, or only CVS? Does this allow you to create site wide activity using views, or limited to user based activity?

#40

Scott Reynolds - June 9, 2009 - 16:02
Status:fixed» closed

its in the -dev release and will be rolled in 1.3 when that is released

#41

wundo - July 13, 2009 - 13:22

Any plans to release 1.3? Views integration is a must for most of the use cases of this module.

 
 

Drupal is a registered trademark of Dries Buytaert.