[英]Drupal Module Development hook_menu() For Semi Static Pages
我的页面绝对不是表单,但是我需要使用一些回调函数来从外部源加载数据并显示(例如,校园中的建筑物列表及其可访问性信息)。
我需要的是登陆列表页面(列出所有建筑物)和“查看单个建筑物”页面。 另外,我在一个页面上提供您的学生ID并查看有关测试程序的信息。 最后,我有一个页面,该页面基本上是一种表单(过去我曾经成功完成过此表单)。
现在,我有建筑名单的工作,但是我做了小改动,它停止工作!
目前,我的hook_menu()函数如下所示:
<?php
/**
* Implementation of hook_menu()
*/
function disability_menu()
{
$items = array();
// Ignore me, shell
$items['quickreg'] = array(
'title' => 'Quick Registration',
'description' => t(''),
'page callback' => 'drupal_get_form',
'page arguments' => array(),
'file' => 'disability.quickreg.view.inc',
'access arguments' => array('access quick registration system'),
'type' => MENU_SUGGESTED_ITEM,
);
$items['tests/status'] = array(
'title' => 'Test Status Results',
'description' => t('Check on the status of your tests'),
'page callback' => 'disability_view_testing_status',
'page arguments' => array(),
'file' => 'disability.tests.view.inc',
'access arguments' => array('access test check information'),
'type' => MENU_CALLBACK,
);
$items['tests'] = array(
'title' => 'Testing Services',
'description' => t('Check on the status of your tests'),
'page callback' => 'disability_view_testing',
'page arguments' => array(),
'file' => 'disability.tests.view.inc',
'access arguments' => array('access test check information'),
'type' => MENU_SUGGESTED_ITEM,
);
$items['access/%building'] = array(
'title' => 'Campus Accessibility Guide',
'description' => t('A summary list of detailed accessibliity information about each building on the A&M campus'),
'page callback' => 'disability_view_access',
'page arguments' => array(1),
'file' => 'disability.access.view.inc',
'access arguments' => array('access building access information'),
'type' => MENU_SUGGESTED_ITEM,
);
return $items;
}
在进行一些更改之前,我必须使“校园无障碍指南”的菜单项正确显示(当然,在启用后)。 /access
URL可以正确显示所有建筑物的列表, /access/12345
可以正确显示ID#12345的单个记录。
现在access/%building
菜单项甚至没有显示出来,甚至发送URL /access
到一个重定向循环(使我认为它传递的东西 ,它发送它变成一个重定向到该视图特定功能的ID /access
时, ID不存在)。
谁能告诉我我做错了什么或需要做什么来支持2个主题页面: /access
和/access/%building
url模式?
如果您要对网址执行操作,则只能在网址中使用%name而不是%。 Drupal在用户和节点的整个地方都可以做到这一点,这非常聪明,因为您只需要一个地方就具有加载用户或节点的代码,但是它却在很多地方得到了使用。 在这种情况下,我敢打赌要创建一个功能来加载建筑物有点过大。 另一方面,这样做的好处是,如果找不到对象,则可以进行404处理。 最好的解决方案实际上取决于您要如何处理不存在的建筑物。 您甚至可以使“校园无障碍指南”功能处理404,这将使这两个选项或多或少相等。 我会去找你最容易做的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.