如何在Drupal中调用自定义模块

时间:2017-04-12 14:11:13

标签: php drupal

我是Drupal的新手,我使用PHP制作了一个自定义模块,显示了学生列表信息,并想点击子菜单项,命名为学生信息。请通过逐步的步骤指导我。

1 个答案:

答案 0 :(得分:1)

寻找生成"页面回调的起始位置" (基本上使一个url在drupal中活动)将是hook_menu。正如建议的那样看一下文档,但实际上让你的回调工作的起点是my_module.module文件:

/**
 * Implements hook_menu().
 */
function my_module__menu() {
    $items = array();

    $items['student-info'] = array(
        'title' => 'Student Info', // This becomes the page title
        'description' => 'Information about students.', // this is the link description
        'page callback' => 'function_name_that_outputs_content', // this is the page callback function that will fire
        'type' => MENU_CALLBACK, // this is the type of menu callback, there are several that you can use depending on what your needs are.
    );

    return $items; // make sure you actually return the items.
}

/**
 * Output the page contents when someone visits http://example.com/student-info.
 */
function function_name_that_outputs_content() {
    $output = 'My page content'

    return $output;
}