计划中的东西总是难以完成。
今天做完的:读完了Pro Drupal Development的第三章;因为做Code Review的关系,又把第七章读了一点;第三章的notes:
Drupal Learn - Chapter 3:
1. How to assign actions to triggers:
i) Method 1: define by functions directly:
create a function: module_hook(&$node, $op, $a3=NULL, $a4 = NULL);
where hook means the trigger name
Parameters' meaning (my understanding):
&$node: passed by reference, the node trigging the acton (contains the node info)
$op: current operations -- view, insert, etc
$a3, $a4: other possible additional information; NULL by default
ii) Method 2: define the GUI
create a function named "hoo]k_action_info()", in which one should define:
an array with the key "method", e.g.: info['key'], where the 'key' is a function to
be defined later; in that array, one should include:
a) type;
b) description;
c) configurable -- true means one can configure it in Admin > Site Config > Actions;
d) hooks -- an array in the form of 'key' => array( of actions); where key is the
module name and the array is a list of actions-triggers can be assigned to that
action.
If the key is 'any', and value is ture, it menas any module with any action can
do.
2. Write a simple action
based on the method 2 in 1, setting the configurable to be false;
a programmer just define any action they want in the function named previously
3. Write an advanced action and its associated configuration form
the configuration form:
it's defined by a function, with the name defined earlier, plus _form.
one may define different IDs (or names) to that field
submitting the form:
functionName_form_submit($form,$form_state);
it would return an array of values to be saved in the DB table "action", with the
information serialized
Validate the forom:
before submitting the form, one may validate it by defining a function []_validate
write the advanced action:
based the method 2 in 1, setting the configurable to be true;
it would take two parameters: $obejct, $context; $object is the one currently being
acting upon, and $context is
4. Create and rename instances of advanced actions using the actions
administration page
This is very easy, just define it in the corresponding admin page.
这是唯一做完的事情。今天还是浪费了不少时间啊~光吃饭就花了2个小时,全算上。
明天(抑或今天)要做的事情:
1. 早上跑步;
2. Pro Drupal Development
3. Code Review -- 读完 Reports 的module