[英]Sitemap custom module
I am writing a custom module for site map in drupal 7. What I had done is below. 我在drupal 7中编写了一个用于站点地图的自定义模块。
function escorts_sitemap_render_menu ($menu)
{
$output = "<ul>";
foreach ($menu as $item)
{
$link = $item["link"];
if ($link["hidden"])
{
continue;
}
$output .= "<li><a href=\"" . check_url(url($link["href"], $link["options"])) . "\">" . $link["title"] . "</a></li>";
if ($item["below"])
{
$output .= sitemap_render_menu($item["below"]);
}
}
$output .= "</ul>";
return $output;
}
function escorts_sitemap_content ()
{
$output = "<h1>Escorts Sitemap</h1>";
$output .= "<ul class=\"site_map_list\">";
$output .= sitemap_render_menu(menu_tree_all_data("main-menu"));
return $output;
}
function escorts_sitemap_menu ()
{
$items = array();
$items["sitemap"] = array (
"title" => "Escorts Sitemap",
"page callback" => "escorts_sitemap_content",
"access arguments" => array("access content"),
"type" => MENU_CALLBACK);
return $items;
}
then in template.php I implemented hook_theme too, below is the code : 然后在template.php中我也实现了hook_theme,下面是代码:
function escorts_theme() {
return array(
'escorts_sitemap_content' => array(
'render element' => 'content',
'template' => 'page--sitemap',
'path' => drupal_get_path('theme', 'escorts') . '/templates'
),
);
}
But it is not appearing as I have my custom template file page--sitemap.tpl.php
, can any one please guide me. 但是它没有出现,因为我有我的自定义模板文件
page--sitemap.tpl.php
,任何人都可以指导我。 But now what should I write in page--sitemap.tpl.php
in order to render my sitemap 但是现在我应该在
page--sitemap.tpl.php
写什么page--sitemap.tpl.php
来渲染我的站点地图
Maybe You should try next: 也许您应该尝试下一个:
function escorts_theme() {
return array(
'escorts_sitemap_content' => array(
'variables' => array('content' => NULL)
/**
* I would not call template like this, cause it looks like
* pattern page--[node-type]
*/
'template' => 'page--sitemap',
)
);
}
And inside of menu callback function 以及菜单回调函数内部
function escorts_sitemap_content () {
$output = "<h1>Escorts Sitemap</h1>";
$output .= "<ul class=\"site_map_list\">";
$output .= sitemap_render_menu(menu_tree_all_data("main-menu"));
return theme('escorts_sitemap_content', $output);
}
This is one of ways. 这是方法之一。 Also look in preprocess functions, and Drupal theme layer at all.
还可以查看预处理功能和Drupal主题层。 And maybe ready module XML sitemap will be useful.
也许就绪的模块XML网站地图会很有用。 Also be careful, if file is really located there.
如果文件确实位于此处,也要小心。
And in template file just paste 并在模板文件中粘贴
<?php print $content; ?>
Regards 问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.