覆盖 Drupal7 中的回调函数
Override callback function in Drupal7
我正在使用博客模块。我可以使用 URL: http://localhost/drupal/blog
访问它。我发了一些帖子。
在博客内容类型中,我添加了一个字段,例如发布日期。当我打开相同的 URL http://localhost/drupal/blog
时,博客文章将按提交日期排序。
现在我希望帖子应该按新添加的字段 "posted_date" 使用顺序列出。我不想更改 blog.pages.inc 页面中定义的默认功能。
请建议!
在自定义模块的 module_name.module 文件中创建此函数。
例如:sites/all/modules/custom/module_name/moduleName.module
/**
* Implements hook_menu().
*/
function moduleName_menu() {
$items['blog'] = array(
'title' => 'Blogs',
'page callback' => 'blog_list',
'access callback' => TRUE,
'file' => 'page_name.inc',
'type' => MENU_CALLBACK
);
}
创建文件moduleName.pages.inc并定义回调函数。
Exm: sites/all/modules/custom/moduleName/moduleName.pages.inc
function blog_list() {
return t('welcome blog');
}
希望对你有用,干杯!
我正在使用博客模块。我可以使用 URL: http://localhost/drupal/blog
访问它。我发了一些帖子。
在博客内容类型中,我添加了一个字段,例如发布日期。当我打开相同的 URL http://localhost/drupal/blog
时,博客文章将按提交日期排序。
现在我希望帖子应该按新添加的字段 "posted_date" 使用顺序列出。我不想更改 blog.pages.inc 页面中定义的默认功能。 请建议!
在自定义模块的 module_name.module 文件中创建此函数。
例如:sites/all/modules/custom/module_name/moduleName.module
/**
* Implements hook_menu().
*/
function moduleName_menu() {
$items['blog'] = array(
'title' => 'Blogs',
'page callback' => 'blog_list',
'access callback' => TRUE,
'file' => 'page_name.inc',
'type' => MENU_CALLBACK
);
}
创建文件moduleName.pages.inc并定义回调函数。
Exm: sites/all/modules/custom/moduleName/moduleName.pages.inc
function blog_list() {
return t('welcome blog');
}
希望对你有用,干杯!