0

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
1
  • You can remove the reference to 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 Dec 23, 2013 at 19:29

1 Answer 1

0

The thing is that the system registers an action with the system name beep_beep_action and probably stores that in a cache. That way it's easier and faster to access the right function in your files. I've however not found that cache, nor a way to clear it.

There are three things you can do:

  • Accept that all others who install your module will see it right.
  • Rename beep_beep_action and beep_beep_action() to something else and you will register a fresh action.
  • Open the database and find and remove the stored action. (But only if you know what you are doing.)

I'd go for the second approach.

1
  • Neograph734. Thank you very much. I did the third bullet there. It wasn’t bad and luckily my tutorial book IS comprehensive enough to talk about the storage of actions in the database tables. I used "phpmyadmin" and went to the actions table. In that table it was very easy to recognize the action called beep_beep_action() and I deleted it. Afterwards I had to unclick (unactivate) the beep module then click (activate) the Beep module I created. I assume Drupal had to rebuild the entry in the database that way. Sure enough beep elegantly has shown up now. THANK YOU and merry Christmas.
    – Dr. Dan
    Dec 24, 2013 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.