2017-04-12 47 views
-2

我是Drupal的新手,我使用PHP制作了一个自定义模块,它显示学生信息列表,并且想要调用它,点击子菜单项,名为学生信息。请引导我逐步步骤程序。如何在Drupal中调用自定义模块

+0

欢迎来到Stack,Neetu!请给我们一些代码和例子,以便我们可以帮助您解决您的问题。 –

+1

请在阅读文档之前阅读以下内容:https://www.drupal.org/docs/7/creating-custom-modules – Fky

回答

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; 
}