【发布时间】:2014-10-13 18:24:27
【问题描述】:
我正在尝试使用 Drupal 7 开发一个 Web 应用程序。我想创建自己的 html 页面并将它们包含在我的 drupal 中。我已经看到,在 drupal 示例模块中给出的这个示例中,hook_menu API 是可能的(见下文)。当你想创建一个页面“Hello World Technology”时,这种方法很酷,但是如果我想包含更复杂的 html 页面怎么办?我是否必须将我的 500 行 html 代码放在关联数组 '#markup' 中并转义所有 " 或 ' 字符?我永远不会以这种速度完成我的网络应用程序...
你们能帮我或建议我吗?
非常感谢
function page_example_menu() {
// This is the minimum information you can provide for a menu item. This menu
// item will be created in the default menu, usually Navigation.
$items['examples/page_example'] = array(
'title' => 'Page Example',
'page callback' => 'page_example_description',
'access callback' => TRUE,
'expanded' => TRUE,
);
$items['examples/page_example/simple'] = array(
'title' => 'Simple - no arguments',
'page callback' => 'page_example_simple',
'access arguments' => array('access simple page'),
);
return $items;
}
function page_example_description() {
return array(
'#markup' =>
t('<p>The page_example provides two pages, "simple" and "arguments".</p><p>The <a href="@simple_link">simple page</a> just returns a renderable array for display.</p><p>The <a href="@arguments_link">arguments page</a> takes two arguments and displays them, as in @arguments_link</p>',
array(
'@simple_link' => url('examples/page_example/simple', array('absolute' => TRUE)),
'@arguments_link' => url('examples/page_example/arguments/23/56', array('absolute' => TRUE)),
)
),
);
}
function page_example_simple() {
return array('#markup' => '<p>' . t('Simple page: The quick brown fox jumps over the lazy dog.') . '</p>');
}
【问题讨论】: