如何向 Drupal 中的 XML Sitemap 模块生成的站点地图添加视图?
我的 Drupal 6 视图有几个参数。我想将每个唯一的参数/页面集添加到由 Drupal 中的 XML Sitemap 模块创建的站点地图中。我有一个自定义模块,它为传递到视图中的每个可能的参数组合创建一个菜单项,因为它们的数量有限。
我尝试遵循以下指示: http://drupal.org/node/507674 但这没有用。
然后我尝试使用这个优秀的评论以编程方式添加这些链接:
我将所有链接构建在数组 $links 中。这是一个典型的数组条目:
$links[] = array(
'type' => 'mymodulename',
'id' => '3000-10000',
'loc' => 'washington-dc',
'lastmod' => time(),
'changefreq' => 4600,
'priority' => 0.5,
);
我试图描述 URL:
example.com/washington-dc/3000-1000
然后我循环整个 $links 数组来保存每个链接:
foreach($links as $link) {
xmlsitemap_link_save($link);
}
最后,所有这些代码都在函数中:
mymodule_xmlsitemap_links()
我从 hook_cron 调用它:
function mymodule_cron() {
mymodule_xmlsitemap_links();
return true;
}
我已经确认:
- 我的 hook_cron()在 cron 期间调用
- 仅保存 $links 中的一个链接
- sitemap 模块设置中要处理的链接总数设置为 250,对于我的 $links 数组(~150)和现有站点地图(47 个链接)来说绰绰有余
- 日志显示 XML 站点地图生成正在运行,并且没有报告
任何错误 知道我做错了什么吗?
I have a Drupal 6 view that has several arguments. I want to add each unique set of arguments / page to the sitemap created by the XML Sitemap module in Drupal. I have a custom module that creates a menu item for each possible argument combination that is passed into the view, as there are a finite number of them.
I tried following these directions:
http://drupal.org/node/507674
but that didn't work.
I then tried to add these links programmatically using this excellent comment:
http://drupal.org/node/711100#comment-3150592
However, of the 150+ links I create in a loop of calls to xmlsitemap_link_save(), only 1 was ever saved. The link entry did not possesses any unique characteristics I could detect when compared to other entries that did not get added to the site map.
I build all the links in an array $links. Here is a typical array entry:
$links[] = array(
'type' => 'mymodulename',
'id' => '3000-10000',
'loc' => 'washington-dc',
'lastmod' => time(),
'changefreq' => 4600,
'priority' => 0.5,
);
I am trying to describe the URL:
example.com/washington-dc/3000-1000
I then loop the entire $links array to save each link:
foreach($links as $link) {
xmlsitemap_link_save($link);
}
Finally, all of this code is in the function:
mymodule_xmlsitemap_links()
which I call from hook_cron:
function mymodule_cron() {
mymodule_xmlsitemap_links();
return true;
}
I have confirmed that:
- My hook_cron() is called during cron
- Only one link from $links is saved
- The setting for total number of links to process in the sitepmap module settings is 250, more than enough for my $links array (~150) and the existing site map (47 links)
- The log shows the XML sitemap generation running and no errors are reported
Any idea what I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)