将面包屑链接重定向到特定页面

发布于 2024-12-26 18:15:25 字数 262 浏览 0 评论 0原文

在我网站的每个页面上,页面内容上方都有面包屑链接。我想要做的是更改链接,以便当它是“主页>事件>示例”时,“事件”链接会将用户重定向到事件页面而不是类别页面。

总之,目前,单击“事件”面包屑链接会将您带到“事件”帖子的类别页面。我希望它将用户带到特定的事件列表页面。

这样做的最佳方法是什么?我最初的想法是编辑“category-3.php”来复制“事件”页面,但有更好的方法吗?我想对站点上面包屑链接中“事件”所在的每个场景执行此操作。

提前致谢。

On each page of my website I have breadcrumb links above the page content. What I want to do is change the link so that when it is 'Home>Events>Example', the 'Events' link will redirect users to an events page instead of a category page.

So in summary, at the minute, clicking the Events breadcrumb link brings you to a category page of Event posts. I want it to instead bring users to a specific Event listings page.

What's the best way of doing this? My initial thought was to edit 'category-3.php' to replicate the Events page, but is there a better way? I want to do this for every scenario across the site where 'Events' is in the breadcrumb links.

Thanks in advance.

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

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

发布评论

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

评论(1

笑忘罢 2025-01-02 18:15:25

如果没有看到面包屑的代码,我将不得不做出一些假设。我想象它会在某个地方迭代一个脚本,根据页面结构构建面包屑。如果发现该循环,则可以对其执行 str_replace,同时假设事件属于特定类别,且 URL 始终保持不变。

因此,如果您找到循环并找到保存事件链接的变量,您可以按照以下示例进行操作:

//crumb would be the variable that helps to build the entire bread crumb in the loop through .=
//e.g. $mainBreadCrumb.=$crumb each time the loop makes a pass

$crumb = '<a href="index.php/category-3.php/">Events</a>';

$crumb = str_replace("<a href="index.php/category-3.php/">Events</a>", "<a href="eventspage.php">Events</a>", $crumb);

假设原始事件面包屑链接没有更改,这应该可以完成工作。如果您需要进一步帮助,请发布面包屑代码。

Without seeing the code for the breadcrumb I'm going to have to make some assumptions. I imagine it iterates through a script somewhere that builds the breadcrumb based on the page structure. If you find that loop you can do an str_replace on it, also assuming that events pertains to a specific category with a URL that always remains the same.

So if you find the loop and find the variable that holds the link for event you can follow this example:

//crumb would be the variable that helps to build the entire bread crumb in the loop through .=
//e.g. $mainBreadCrumb.=$crumb each time the loop makes a pass

$crumb = '<a href="index.php/category-3.php/">Events</a>';

$crumb = str_replace("<a href="index.php/category-3.php/">Events</a>", "<a href="eventspage.php">Events</a>", $crumb);

That should get the job done, again, assuming that the original Events breadcrumb link does not change. If you need further help post the breadcrumb code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文