2012-02-23 23 views
1

我已經爲userbeep_action_info()鉤子添加了第二個元素,我打算將其作爲新動作,但是當我在觸發器頁面中檢查它時,它不會出現。第一項userbeep_beep_action顯示,但不是第二項。爲什麼是這樣?是否因爲它是可配置的,它需要額外的信息出現?我的書讓我在這個階段檢查它的存在,但它沒有出現。Drupal 7 - 爲什麼我的動作沒有出現在觸發器菜單中?

<?php 

/** 
* @file 
* Writes to the log every time a user logs in or edits a node. 
*/ 

/** 
* Implementation of hook_action_info(). 
*/ 
function userbeep_action_info() { 
    return array(
     'userbeep_beep_action' => array(
      'type' => 'system', 
      'label' => t('Beep annoyingly'), 
      'configurable' => FALSE, 
      'triggers' => array('node_view', 'node_insert', 'node_update', 'node_delete') 
     ), 
     'userbeep_multiple_beep_action' => array(
      'type' => 'system', 
      'label' => t('Beep multiple times'), 
      'configurable' => TRUE, 
      'triggers' => array('node_view', 'node_insert', 'node_update', 'node_delete') 
     ) 
    ); 
} 

/** 
* Simulate a beep. A Drupal action. 
*/ 
function userbeep_beep_action() { 
    watchdog('beep', 'Beep! at ' . ''); 
} 
+1

我知道你正在使用的書。您需要爲此網站添加書籤以供將來參考 - http://www.drupalbook.com/errata_overview – SpaceBeers 2012-02-23 14:30:26

+0

Thankyou,解決了這個問題。 – persepolis 2012-02-23 14:55:09

+0

不客氣。如果它對你有幫助,請接受下面的答案。除了所有的錯誤,這是一本好書。 – SpaceBeers 2012-02-23 14:56:43

回答

3

從本書的錯誤更正網站 - http://www.drupalbook.com/errata3

Error: The screenshot in Figure 3.4 is of the wrong overlay. (What is shown in Figure 3.4 is not available until an instance of the advanced action has been created as described on pp. 43-44 and in Figure 3.5.)

Correction: What should be shown in Figure 3.4 is the overlay accessed by clicking the Configuration link in the top menu and then clicking on the Actions link in the Configuration page, and finally scrolling to the bottom of the overlay to the "Create an Advanced Action" drop-down select box.

你立足的前提是你的代碼是不工作的數字是不正確的。完成本章的其餘部分,你會得到它的工作。使用上面的資源來追查本書中的更多錯誤。

提示:有不少...

0

它沒有顯示出來,因爲高級(配置)操作需要創建和配置一次在代碼中定義:/admin/config/system/actions,其中作爲簡單的動作沒有。它也可能需要首先定義配置表單和操作。

相關問題