【问题标题】:How to call Custom Module in Drupal如何在 Drupal 中调用自定义模块
【发布时间】:2017-04-12 14:11:12
【问题描述】:

我是 Drupal 的新手,我使用 PHP 制作了一个自定义模块,它显示了学生的信息列表,并希望在单击子菜单项时调用它,命名为学生信息。请按步骤指导我。

【问题讨论】:

标签: php drupal


【解决方案1】:

寻找生成“页面回调”(本质上是在 drupal 中激活 url)的起始位置是 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;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多