【发布时间】:2016-04-25 14:13:55
【问题描述】:
我想使用模块在管理端创建页面。我需要提到使用 hook_menu() 的自定义链接页面。从浏览器访问链接后,我想显示一些链接,以便从另一个网站调用另一个静态链接。
例如:
我想创建管理员/链接列表:自定义 url
在此页面上单击此按钮后,结果将类似于带有按钮的表格列表,用于从另一个网站导航该静态链接。
我已经创建了以下内容。
通过使用以下代码,我创建了带有自定义模板文件分配的自定义页面,通过传递静态链接并将其打印在自定义模板页面中。请注意,我刚刚在模板页面中打印了数组。格式保留。
<?php
// Created Custom URL for accesing the static links
function test_menu() {
$items['admin/list-of-links'] = array(
'title' => 'List Section',
'page callback' => 'list_section',
'access arguments' => array('administrator'),
);
}
// Created Page Callback for assigning the variable for the theme
function list_section() {
$static_links = array("www.google.com", "www.facebook.com");
return theme('test_link', array('static_links' => $static_links));
}
// Assigned the template for the page that we have created
function test_theme($existing, $type, $theme, $path) {
return array(
'test_link' => array(
'template' => 'static-link-listing',
'path' => drupal_get_path('theme', 'seven') . "/templates"
),
);
}
//Created Template File : themes/seven/templates/static-link-listing.tpl.php
// And after that, I am getting the result.
// Now after that, we will format what output we need.
echo "<pre>";
print_r($static_links);
?>
【问题讨论】: