Code Igniter:导航和导航问题基于电流控制器/方法的模板

发布于 2024-11-06 02:21:26 字数 376 浏览 0 评论 0原文

我的控制器和方法映射到部分和页面,因此我使用它来突出显示当前导航项并显示页面模板(通过 $this->router->class..)。但我遇到了一些问题,我有以下医生测试结果的结构:

website.com/doctor/results/

因此“医生”控制器有一个方法“结果”,可以加载结果页面列表。一切都好。

但列出的每个结果旁边都有一个链接,即“查看详细信息”以显示该测试的详细信息。从功能上讲,单击此链接会将您带到“测试”控制器,该控制器具有自己的“视图”方法,以显示该特定测试的详细信息页面。但显然你应该仍然在“医生”部分,“结果”小节。

我不知道如何实现这一目标?无需重新考虑整个导航(到目前为止看起来相当不错)。

My controllers and methods map to sections and pages so I use that to highlight current navigation items and show page templates (via $this->router->class..). But I've struck a bit of a problem, I have the following structure for doctor test results:

website.com/doctor/results/

So a 'doctor' controller has a method 'results' that loads a page listing of results. All good.

But there is a link next to each result listed, i.e. 'view details' to show details of that test. Functionally, clicking this link takes you to a 'test' controller with it's own method 'view' to show a page of details for that particular test. But visibly you should still be in the 'doctor' section, 'results' subsection.

I'm not sure how to achieve that? without rethinking the navigation as whole (which up until now seemed pretty good).

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

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

发布评论

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

评论(2

℡寂寞咖啡 2024-11-13 02:21:26

常见的方法是使用 路由

在文件 / application/config/routes.php,添加此路由:

$route['doctor/test-results/(:any)'] = 'test/view/$1';

其中 test-results 是您想要的 url 段(您将链接到的页面)。

这基本上是说:

任何 doctor/test-results/something 的 url 都应该加载 test/view/something

您可以使用路由做很多事情。 在用户指南中阅读有关路由的更多信息

请 。 router->class/method 不起作用,请尝试尝试 中的一些功能统一资源标识符类

The common way to do this is to use a route:

In the file /application/config/routes.php, add this route:

$route['doctor/test-results/(:any)'] = 'test/view/$1';

Where test-results is whatever you want the url segment to be (the page you'll link to).

This basically says:

Any url that is doctor/test-results/something should really load test/view/something

You can do quite a bit with routes. Read more on routing in the User Guide

If you find $this->router->class/method is not working out, try experimenting with some functions from the URI Class

山有枢 2024-11-13 02:21:26

您可以在控制器目录中创建一个名为“doctor”的子目录,然后使用“result”作为控制器名称。

要显示所有结果,您将使用主要的“index()”方法。然后,您可以使用另一个方法调用“test()”来显示您的测试。

示例:

目录结构:

application/controllers/doctor/results.php

您的 results.php 文件将如下所示:

function index()
{
// all results here
}

function test()
{
// test result display here
}

You could create a subdirectory in your controllers directory thats called "doctor" and then use "result" as your controller name.

To display all your results you would then use the main "index()" method. You could then have a another method call "test()" to display your tests.

Example:

Directory structure:

application/controllers/doctor/results.php

Your results.php file would then be like so:

function index()
{
// all results here
}

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