Code Igniter:导航和导航问题基于电流控制器/方法的模板
我的控制器和方法映射到部分和页面,因此我使用它来突出显示当前导航项并显示页面模板(通过 $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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
常见的方法是使用 路由:
在文件
/ application/config/routes.php
,添加此路由:其中
test-results
是您想要的 url 段(您将链接到的页面)。这基本上是说:
您可以使用路由做很多事情。 在用户指南中阅读有关路由的更多信息
请 。 router->class/method 不起作用,请尝试尝试 中的一些功能统一资源标识符类
The common way to do this is to use a route:
In the file
/application/config/routes.php
, add this route:Where
test-results
is whatever you want the url segment to be (the page you'll link to).This basically says:
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您可以在控制器目录中创建一个名为“doctor”的子目录,然后使用“result”作为控制器名称。
要显示所有结果,您将使用主要的“index()”方法。然后,您可以使用另一个方法调用“test()”来显示您的测试。
示例:
目录结构:
您的 results.php 文件将如下所示:
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:
Your results.php file would then be like so: