如何在Drupal中调用自定义模块
答
查找生成“页面回调”(实际上使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;
}
欢迎来到Stack,Neetu!请给我们一些代码和例子,以便我们可以帮助您解决您的问题。 –
请在阅读文档之前阅读以下内容:https://www.drupal.org/docs/7/creating-custom-modules – Fky