Hello, I am trying to get heartbeat views for groups to display in a block. I am using the instructions found here http://heartbeat.menhireffect.be/docs/how-create-heartbeat-activity-view...

So far, I am having no luck. When viewing the group, I get no results in my block. If I put the block on non-group pages, it returns all of my heartbeat messages.

I feel that I am missing something obvious, but I don't know... Anyhow, I have included my view export if you wish to see it.

Thanks in advance!

$view = new view;
$view->name = 'class_heatbeat';
$view->description = '';
$view->tag = 'Classes';
$view->view_php = '';
$view->base_table = 'heartbeat_activity';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'message_id' => array(
    'label' => 'Activity message id',
    'required' => 0,
    'id' => 'message_id',
    'table' => 'heartbeat_activity',
    'field' => 'message_id',
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'message' => array(
    'label' => 'Message',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'exclude' => 0,
    'id' => 'message',
    'table' => 'heartbeat_activity',
    'field' => 'message',
    'relationship' => 'none',
  ),
  'timestamp' => array(
    'label' => 'Action\'s timestamp',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'date_format' => 'small',
    'custom_date_format' => '',
    'exclude' => 0,
    'id' => 'timestamp',
    'table' => 'heartbeat_activity',
    'field' => 'timestamp',
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'timestamp' => array(
    'order' => 'DESC',
    'granularity' => 'second',
    'id' => 'timestamp',
    'table' => 'heartbeat_activity',
    'field' => 'timestamp',
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'access_type' => array(
    'operator' => '=',
    'value' => array(
      'access' => 'OgHeartbeat',
      'value' => '',
      'min' => '',
      'max' => '',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'access_type',
    'table' => 'heartbeat_activity',
    'field' => 'access_type',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler = $view->new_display('block', 'Class Heatbeat', 'block_1');
$handler->override_option('title', 'Class Activity');
$handler->override_option('empty', 'No activity for this class');
$handler->override_option('empty_format', '1');
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
CommentFileSizeAuthor
#3 rule-config.jpg51.68 KBKirk
#3 argument-config.jpg88 KBKirk

Comments

Kirk’s picture

Good news is, I figured out how to do this. Bad news is, it took a lo of messing around till I figured it out. Basically, I had to create a rule for group content that sets the "Node target Id" to the Group ID when a user submits group content.

I was then able to toss an argument on there to make it work.

A little difficult at first, but I think it's working. I'll try to put together some documentation when I have some time.

Hardrocker’s picture

Were you able to put a documentation together? I'm struggling to get this feature to work and my client's deadline is past overdue.

Kirk’s picture

StatusFileSize
new88 KB
new51.68 KB

Sorry, Hardrocker. I haven't had time to do so yet as I have been busy. Properly documenting this is on my list of things to do as soon as I have time. However, here are the 2 magic components, I hope you know enough to make sense of these.

I am assuming you have set up Rules to record the activities you wish to capture. Once you have your rule, you will want to make sure to set up the "Node Target Id" as seen on your rule config screen. This is the field you need to edit -> http://drupal.org/files/issues/rule-config.jpg

Then, you will go over to your view and add an argument of the type "Heartbeat activity: Node Target". For the argument settings, you will want to set it up like this -> http://drupal.org/files/issues/argument-config.jpg

Brief explanation: The first step is what actually records the OG Context to the activity messages table. The second step just filters the messages to only show those messages that match the group context of the page the user is viewing.

I hope that helps, I'm a little rushed right now.

Hardrocker’s picture

Hi Kirk,
Thanks for the useful bits of info. I have gotten the rules configuration the way you outlined (I would have never guessed that) but I'm stumped with creating the view now. Can you please add a screenshot of your view please if its not too much trouble. Many thanks for your time and patience.

Kirk’s picture

Here is an export of my view. Should be a little quicker than trying to explain it all. You'll probably need to modify it a bit since this is probably pretty specific to my site.

$view = new view;
$view->name = 'class_heatbeat';
$view->description = '';
$view->tag = 'Classes';
$view->view_php = '';
$view->base_table = 'heartbeat_activity';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'message_id' => array(
    'label' => 'Activity message id',
    'required' => 0,
    'id' => 'message_id',
    'table' => 'heartbeat_activity',
    'field' => 'message_id',
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'timestamp' => array(
    'label' => 'Action\'s timestamp',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'date_format' => 'time ago',
    'custom_date_format' => '1',
    'exclude' => 0,
    'id' => 'timestamp',
    'table' => 'heartbeat_activity',
    'field' => 'timestamp',
    'relationship' => 'none',
  ),
  'message' => array(
    'label' => 'Message',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'exclude' => 0,
    'id' => 'message',
    'table' => 'heartbeat_activity',
    'field' => 'message',
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'timestamp' => array(
    'order' => 'DESC',
    'granularity' => 'second',
    'id' => 'timestamp',
    'table' => 'heartbeat_activity',
    'field' => 'timestamp',
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'nid_target' => array(
    'default_action' => 'default',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'breadcrumb' => '',
    'default_argument_type' => 'og_group_node',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'break_phrase' => 0,
    'not' => 0,
    'id' => 'nid_target',
    'table' => 'heartbeat_activity',
    'field' => 'nid_target',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
      '5' => 0,
      '7' => 0,
      '3' => 0,
      '6' => 0,
      '8' => 0,
      '4' => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_fixed' => '',
    'default_argument_user' => 0,
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'poll' => 0,
      'class' => 0,
      'class_assignment' => 0,
      'class_discussion' => 0,
      'class_event' => 0,
      'class_homework' => 0,
      'class_lecture' => 0,
      'discussion' => 0,
      'page' => 0,
      'profile' => 0,
      'story' => 0,
      'ws_submission' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '2' => 0,
      '3' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_node_flag_name' => '*relationship*',
    'validate_argument_node_flag_test' => 'flaggable',
    'validate_argument_node_flag_id_type' => 'id',
    'validate_argument_user_flag_name' => '*relationship*',
    'validate_argument_user_flag_test' => 'flaggable',
    'validate_argument_user_flag_id_type' => 'id',
    'validate_argument_is_member' => 'OG_VIEWS_DO_NOT_VALIDATE_MEMBERSHIP',
    'validate_argument_group_node_type' => array(
      'class' => 0,
    ),
    'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array(
  'access_type' => array(
    'operator' => '=',
    'value' => array(
      'access' => 'OgHeartbeat',
      'value' => '',
      'min' => '',
      'max' => '',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => 'access_type_op',
      'label' => 'Heartbeat activity: Heartbeat user access',
      'use_operator' => FALSE,
      'identifier' => 'access_type',
      'remember' => FALSE,
      'single' => TRUE,
      'optional' => TRUE,
    ),
    'id' => 'access_type',
    'table' => 'heartbeat_activity',
    'field' => 'access_type',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
  'grouping' => '',
  'override' => 1,
  'sticky' => 0,
  'order' => 'asc',
  'columns' => array(
    'message' => 'message',
    'timestamp' => 'timestamp',
  ),
  'info' => array(
    'message' => array(
      'separator' => '',
    ),
    'timestamp' => array(
      'sortable' => 0,
      'separator' => '',
    ),
  ),
  'default' => '-1',
));
$handler = $view->new_display('block', 'Class Heatbeat', 'block_1');
$handler->override_option('title', '%1 Activity');
$handler->override_option('empty', 'No activity for this class');
$handler->override_option('empty_format', '1');
$handler->override_option('use_ajax', TRUE);
$handler->override_option('use_pager', '1');
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
Hardrocker’s picture

Hi Kirk sorry to be a bother again. I imported the ur views export and it was imported fine. All the fields and settings seems to be in order but the problem still lies where there is no feed for activities within the group context. Do you think there is any settings I may have missed? Please advise and thank you for your time.

Kirk’s picture

The view should create a block. You need to then go to the blocks page and place it where you wish.

Hardrocker’s picture

I have added the block where I wanted it to be. Its still showing "No activity for this class" currently. I don't know what else to look for right now since everything seems to be correct.

Kirk’s picture

And you actually created the message templates and proper rules? If you do that, it should work.

Hardrocker’s picture

So I have to create new templates? Can't the default templates work? I have created a rule for when user saves a node and add the target node ID as you mentioned but nothing. I have not created any more rules as yet since I needed to test and ensure one works before adding more.

Hardrocker’s picture

Hey Kirk I am pleased to say that i have gotten it to work now. I have to admit it was quite simple after all. I am going to try and see if i can scribble a documentation and post it in the handbook or something. Thank you once again for your time and patience. Cheers!

Kirk’s picture

Good to hear! I started working on a pretty in-depth tutorial that I hope to finish soon. But, other projects have been demanding my time.

Hardrocker’s picture

I know the feeling when it comes to time consumption. I was finally able to finish this client's site and move on with other projects. If u need help with the documentation just let me know. Also one thing I noticed there was no way to add user's pic to the feed. I wonder if the developer plans to add this feature in future releases.

Drake’s picture

sub

Stalski’s picture

Status: Active » Closed (fixed)

first of all, sorry for the late answer. However I am really pleased to see that an issue of heartbeat got solved by the community ;)

What Kirk says is correct. The node target and user target Id are meant as extra logic parameters such as the required UID and an optional required NID (in node context).
The approach is that posting a node in a group will have the node as Node variable and the group as NodeTarget variable. If someone joins a group for instance, it is enough to set the group id as Node (no need to have it as target).

So when queries are run (for each stream different), the query will look at those node and node target. It's not as clear as I intended it to be (and indeed once you know it, it's plain simple).

About user pictures: in drupal 7 it is built in. For drupal6 you can follow instructions on the demo site as well. There is a good example page to add custom tokens as well (where the token could be an avatar).
This page sums it up: http://heartbeat.menhireffect.be/docs/adding-user-avatar-stream
With heartbeat_ds installed, you should have the same as in drupal7, the avatar as field available.

Hardrocker’s picture

Hey Kirk I seem to be having some problems. Initially the heartbeat OG activities worked but then suddenly it stopped working. All the settings are correct. Not sure what the problems is. Can you advise if any? Thanks in advance.