SELECT name, filename, throttle FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC
复制代码
throttle用于控制模块是否被加载,不过几乎不用它。
3. Form
Drupal定义了一套很详细的API用于定义表单及相关处理逻辑,包括元素默认值、验证、显示结构及顺序等,并提供了默认的显示结构与样式(虽然这很不实用)。
第一个表单对应一个函数,也称为form_id, Drupal通过drupal_get_form($form_id)来获得该表单的定义并渲染HTML。如下面代码所示:
function user_login(&$form_state) {
global $user;
// If we are already logged on, go to the user page instead.
if ($user->uid) {
drupal_goto('user/'. $user->uid);
}
// Display login form:
$form['name'] = array('#type' => 'textfield',
'#title' => t('Username'),
'#size' => 60,
'#maxlength' => USERNAME_MAX_LENGTH,
'#required' => TRUE,
);
$form['name']['#description'] = t('Enter your @s username.', array('@s' => variable_get('site_name', 'Drupal')));
$form['pass'] = array('#type' => 'password',
'#title' => t('Password'),
'#description' => t('Enter the password that accompanies your username.'),