Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I'm having trouble using this module. Read about this module and looked at the example and default modules and now i want to get going.
Trying to log an activity when a node is inserted
<?php
/**
* Implementation of hook_nodeapi().
*/
function drupal_glue_heartbeat_nodeapi(&$node, $op, $arg = 0) {
if ($op == 'insert') {
drupal_glue_heartbeat_log_activity($node);
}
}
/**
* Callback function to hook into the closet updating action
*/
function drupal_glue_heartbeat_log_activity($node) {
$message_id = 'drupal_glue_node_insert';
$variables = array(
'!user' => l(user_load($node->uid)->name, 'user/' . $node->uid),
'@type' => $node->type,
'!title' => l($node->title, 'node/' . $node->uid)
);
heartbeat_api_log($message_id, $node->uid, 0, $node->nid, 0, $variables, HEARTBEAT_PUBLIC_TO_ALL);
}
But the heartbeat table is still empty...
Comments
Comment #1
Michsk CreditAttribution: Michsk commentedI first ofcourse need to define the templates.
Comment #2
Stalski CreditAttribution: Stalski commented1) Indeed, the template with machine name "drupal_glue_node_insert" needs to exist first.
2) Also, always use the "!"-prefixed variable. This is not the same thing as the placeholders %, ! or @ used in the t-string replacement patterns.
Is this issue now ok or does it still exist? Please notify me if your problems are solved.
Comment #3
Michsk CreditAttribution: Michsk commented1) I'm having trouble with setting up the template, i want to do it trough my module, but can't get it to appear. This is what is confusing me. I'm using heartbeat_defaults as my starting point. So here goes.
The heartbeat api tells me to use
hook_defaults_heartbeat_template_info
. But heartbeat_defaults is usingheartbeat_defaults_heartbeat_template_info
. Shouldn't that beheartbeat_defaults_defaults_heartbeat_template_info
, thats what i would expect when viewing the api.At this moment i'm trying
function drupal_glue_heartbeat_defaults_heartbeat_template_info
but that doesn't display my template.My
ctools_plugin_api
is defined as following:2) ok, got it.
Comment #4
Stalski CreditAttribution: Stalski commentedHi,
The hook is called "heartbeat_template_info", so your module will declare drupal_glue_heartbeat_template_info() ... This is explained in the heartbeat.api.php file incorrectly. The "_defaults" is a left over from the heartbeat_example module where I miscopied the function to .api.php.
Most probably the error you are having, sorry for that. Change the hook function and it should work. I also adjusted the function names so it is correctly explained in the heartbeat.api.php file.
this has also been committed and pushed to git, with credits for you ofcourse.
Sorry for this inconvenience. I am always mad when documentation is not correct of inconsistent, so I understand you pain.
If you still have other issues, let me know.
Comment #5
Michsk CreditAttribution: Michsk commentedOk that's clear, though i'm still unable to get this going.
Module name is
drupal_glue_heartbeat
.Trying to get the hook trough
drupal_glue_heartbeat_heartbeat_template_info()
in mydrupal_glue_heartbeat.heartbeat.inc
file. Myctools_plugin_api()
indrupal_glue_heartbeat.module
is unchanged and still the same as in my comment above.Here is my
drupal_glue_heartbeat_heartbeat_template_info()
It's the most basic version, copied from heartbeat.api.php. Only change is the
messageid
. Once i get this going i am willing to submit some kind of basic tutorial on how to get started with heartbeat trough a custom module and add it to the heartbeat book documentation. I saw your custom website which documents heartbeat but i couldn't find a real start on it, so again, once i get this going i am willing to publish about it.Another thing i came across, though probably not an heartbeat issue, is that ctools help has documented that the api file shoud be
MODULENAME.API.inc
but you are usingheartbeat.api.php
. See ctools/help/export.html line 198. Again i think this is rather an ctools issue since more modules use api.php.Comment #6
Michsk CreditAttribution: Michsk commentedOk, got it working, finally.
The issue was that i had this drupal_glue_heartbeat module, in my drupal_glue module. So:
drupal_glue/module/drupal_glue_heartbeat/drupal_glue_heartbeat.module
and that seems not possible.
Comment #7
Stalski CreditAttribution: Stalski commentedYes, that works fine.
The other thing is not as you understood it. I'll explain it in short.
Ctools allows other modules to defines API's. In this case, heartbeat is an API that defines its exportables through CTools. This means heartbeat is the "owner" of the api.
So if you want to export heartbeat message templates (provided by the owner "heartbeat") then CTools recommends to place those exportables in the file "yourcustommodule.modulewhoprovidestheapi.inc" ==> drupal_glue_heartbeat.heartbeat.inc ...
If you would export your views, it will be in drupal_glue_heartbeat.views.inc.
This has nothing to do with the .api.php hook I use correctly. This is only to show coders how to write the code.
I hope you understand it and thanks for the report.