i'm learning Drupal and was going through this text book to do so: "Pro Drupal 7 Development by Todd Tomlinson".
Chapter 3 of the book teaches readers about hooks actions and triggers. It does this by taking you through the steps of creating a module called beep that involves making a function that implements hook_action_info() to write the word Beep! to log when an event takes place.
The issue I am having is that I can enable the module in the module page and once I do it works and i see the label 'Beep annoyingly' as a selectable option but when I change the label to something else like 'Beep elegantly' it doesn't change. Nothing is updating and it just stays as Beep annoyingly every time. Am I missing something? I've cleared the caches and everything too. I was thinking it might be a simple PHP syntax error but i cannot find it and have been struggling over this for some time now.
I've provided the code below. You should be able to make a module yourself with this. I'd provide the files themselves but I don't see a way to do that in this forum. Can anyone else get the labels to change? If your awesome enough to try this. make sure you have the triggers module enabled first. Thanks!
For the beep.module file:
<?php
/**
* @file
* Provide a simulated beep.
*/
function beep_beep() {
watchdog('beep','Beep!');
}
/**
*Implementation of hook_action_info().
*/
function beep_action_info() {
return array(
'beep_beep_action' => array(
'type' => 'system',
'label' => t('Beep annoyingly'),
'configurable' => FALSE,
'triggers' => array('node_view', 'node_insert', 'node_update', 'node_delete'),
),
);
}
/**
* Simulate a beep. A Drupal action.
*/
function beep_beep_action() {
beep_beep();
}
HERE IS THE CODE FOR THE beep.info FILE.
name = Beep
description = "Simulates a system beep."
package = Pro Drupal Development
core = 7.x
files[] = beep.module
files.module
from the info file, that's auto loaded. And you can add trigger as a dependency:dependencies[] = trigger
. It's a bit neater