修改菜单导航以包含域

发布于 2024-10-24 08:22:14 字数 1105 浏览 2 评论 0原文

如果您想了解我为什么要做我正在做的事情,请了解一些背景知识:

我有一位客户想要在单独的子域上使用 Wordpress 完成一个新博客。他们现有的网站位于 Drupal 上,在此之前我对此没有任何经验。他们在该网站上有相当广泛的导航(多个级别),因此我使用 YQL 将整个导航拉入 WordPress 网站,而不是创建需要在 WordPress 和 Drupal 上更新的导航菜单副本。我知道这对 SEO 不利,但目前我并不担心这一点。

我遇到的问题是 Drupal 网站上的所有链接都不包含 http://domain.com ,因此这些链接在博客网站上都不起作用,因为它们将指向该子域上不存在的相关页面。

总而言之,我想要完成的任务:

我需要 Drupal 生成的每个 href 以“http://domain.com”开头。目前他们只是以“/pagename”开头。我不知道该网站的 Drupal 版本是什么,也不知道如何找到它,抱歉。该网站也使用 Drupal 的 Nice Menu 插件。我已经研究了几个小时的文件,但不知道需要在哪里进行更改。请帮忙!谢谢


编辑:dobeerman提到使用custom_url_rewrite_outbound到settings.php。这似乎已经接近我想要的了。我尝试将其添加到settings.php的末尾:

function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
  global $user;
  $path = 'http://www.reillypainting.com/'.$path;
}

但是,菜单中href的最终结果变成了这个例子:

href="/http%3A/%252Fwww.reillypainting.com/services/sell/rent-your-house"

所以生成Drupal菜单的其他代码试图转义://并且它仍然添加一个/到href 的开头。有人知道如何避免这种情况吗?

Some background if you want to see why I'm doing what I'm doing:

I have a client who wanted a new blog done with Wordpress on a separate subdomain. Their existing website is on Drupal, which I have had 0 experience with prior to this. They have a pretty extensive navigation on that site (multiple levels), so rather than create duplicates of nav menus that would need updated on both wordpress and drupal, I am using YQL to pull in the whole navigation onto the Wordpress website. I know this isn't great for SEO, but at this point I'm not worried about that.

The issue I have is that all of the links on the Drupal website do not include the http://domain.com so that none of the links work on the blog site, because they're going to relative pages on that subdomain that don't exist.

So in summary, what I'm trying to accomplish:

I need each href that Drupal is generating to begin with 'http://domain.com'. Currently they just start with '/pagename'. I have no clue what Drupal version the site is on nor on how to find it, sorry. The site is using Drupal's Nice Menu plugin as well. I've been digging through the files for a couple of hours now, and can't figure out where I need to make the change. Please help! Thanks


Edit: dobeerman mentioned using custom_url_rewrite_outbound to settings.php. This seems to accomplish close to what I want. I tried adding this to the end of settings.php:

function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
  global $user;
  $path = 'http://www.reillypainting.com/'.$path;
}

However, the end result of an href in the menu becomes this example:

href="/http%3A/%252Fwww.reillypainting.com/services/sell/rent-your-house"

So the other code generating Drupal's menu is trying to escape the :// and it's also still adding a / to the beginning of the href. Anyone know how to avoid this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏末染殇 2024-10-31 08:22:14

Drupal 具有 custom_url_rewrite_outbound 功能可以在settings.php中添加

使用此代码

function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
  $options['absolute'] = 1;
}

Drupal has function custom_url_rewrite_outbound you can add to settings.php

Use this code:

function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
  $options['absolute'] = 1;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文