Codeigniter多控制器与许多方法? [英] Codeigniter multiple controllers vs many methods?
问题描述
我有一个网站有很多页面在根位置(例如 / contact
, / about
, / home
, / faq
, / privacy
, / tos
等)。我的问题是这些应该是单独的控制器或一个控制器与许多方法(例如联系
,约
,<$ ?
I have a site that has a lot of pages that lye at the root (ex. /contact
, /about
, /home
, /faq
, /privacy
, /tos
, etc.). My question is should these all be separate controllers or one controller with many methods (ex. contact
, about
, index
within a main.php
controller )?
更新:
我刚刚意识到,默认控制器中的方法不显示在没有默认控制器的URL(即 main / contact
不会自动路由到 / contact
如果main是默认控制器)。因此,您需要进入路由并覆盖每个页
。
UPDATE:
I just realized that methods that are within the default controller don't show in the url without the default controller (ie. main/contact
wont automatically route to /contact
if main is the default controller ). So you would need to go into routes and override each page
.
推荐答案
如果所有这些只是页面,我会建议将它们放在一个单一的控制器。我通常最终把这样的静态页面放到一个页面控制器中,并为每个静态页面放置路由以绕过我的URL中的/ pages。
If all of these are just pages, I would recommend putting them into a single controller. I usually end up putting static pages like this into a 'pages' controller and putting in routes for each static page to bypass the '/pages' in my URLs.
这篇关于Codeigniter多控制器与许多方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!