| 1 |
For developing, there are three hook functions:
|
| 2 |
|
| 3 |
hook_netforum_node_obj_search_on($obj_type_name)
|
| 4 |
hook_netforum_node_obj_order_by($obj_type_name)
|
| 5 |
hook_netforum_node_runtime_special_fields($fields)
|
| 6 |
|
| 7 |
The first takes an object name, and returns an array of columns and descriptions
|
| 8 |
to search on for that object. This shows up when a users is adding a netFORUM
|
| 9 |
node and expands the help searching for an object key.
|
| 10 |
|
| 11 |
The second takes an object name, and returns a string containing a comma
|
| 12 |
separated list of columns to order the results by when searching for an object key.
|
| 13 |
|
| 14 |
Here are two examples:
|
| 15 |
|
| 16 |
function client_custom_netforum_node_obj_search_on($obj_type_name) {
|
| 17 |
$obj_type_name = trim($obj_type_name);
|
| 18 |
switch ($obj_type_name) {
|
| 19 |
case 'Individual':
|
| 20 |
return array('ind_first_name' => 'First Name',
|
| 21 |
'ind_last_name' => 'Last Name',
|
| 22 |
'cst_org_name_dn' => 'Organization Name',
|
| 23 |
);
|
| 24 |
case 'IndividualEmail':
|
| 25 |
return array('eml_address' => 'Email Address',
|
| 26 |
'eml_type' => 'Email Type',
|
| 27 |
);
|
| 28 |
}
|
| 29 |
}
|
| 30 |
|
| 31 |
function client_custom_netforum_node_obj_order_by($obj_type_name) {
|
| 32 |
$obj_type_name = trim($obj_type_name);
|
| 33 |
switch ($obj_type_name) {
|
| 34 |
case 'Individual':
|
| 35 |
return "ind_last_name, ind_first_name";
|
| 36 |
case 'IndividualEmail':
|
| 37 |
return "eml_address, eml_type";
|
| 38 |
}
|
| 39 |
}
|
| 40 |
|
| 41 |
A separate module is recommended, look in the drupal handbook for an outline on how
|
| 42 |
to create modules. Here's a sample client_custom.info file:
|
| 43 |
|
| 44 |
name = Client Customizations
|
| 45 |
description = netFORUM Customizations
|
| 46 |
dependencies = netforum
|
| 47 |
package = "netFORUM"
|
| 48 |
|
| 49 |
|
| 50 |
hook_netforum_node_runtime_special_fields is called when making up the list of fields
|
| 51 |
and descriptions when adding objects. Use this hook to help users when you want to
|
| 52 |
add your own special fields. Here's an example from the netforum_nodes module itself
|
| 53 |
|
| 54 |
function netforum_node_netforum_node_runtime_special_fields(){
|
| 55 |
$fields = array();
|
| 56 |
//These special fields are set at runtime and included here to be helpful
|
| 57 |
$fields['ListRowNumber'] = "SpecialField::Row number of current list result";
|
| 58 |
$fields['ListRowCount'] = "SpecialField::Total number of rows in the most recent list";
|
| 59 |
$fields['ListRowZebra'] = "SpecialField::Toggles between 'stripe' and 'plain' for each list row";
|
| 60 |
return $fields;
|
| 61 |
}
|
| 62 |
|
| 63 |
In turn, any module that implements hook_netforum_node_runtime_special_fields should
|
| 64 |
also call netforum_node_set_runtime_special_fields($fields) to set the values in response to events.
|
| 65 |
Here's the example from the netforum_node module:
|
| 66 |
netforum_node_set_runtime_special_fields(array('ListRowNumber' => $list_row_number,
|
| 67 |
'ListRowCount' => $list_row_count,
|
| 68 |
'ListRowZebra' => $list_row_zebra )
|
| 69 |
);
|