CodeIgniter中的子文件夹
时间:2020-03-06 14:43:12 来源:igfitidea点击:
我是CodeIgniter的新手,我需要一些帮助。我要实现以下内容:
- 通过以下网址查看用户的个人资料:http:// localhost / profile / johndoe
- 通过以下网址管理用户的个人资料:http:// localhost / admin / profile / johndoe
- 能够通过以下方式完成进一步的处理:http:// localhost / admin / profile / create ... and ... http:// localhost / admin / profile / edit / johndoe
我已经创建了管理对象,并对其进行了保护。我是否必须在admin下创建配置文件功能,并使用URI进行相应处理?有没有更好的办法?
解决方案
这不是一个好主意。
如果要实现这些URL,则需要两个控制器:
- 配置文件,具有" index"功能
- 管理员,具有"个人资料"功能
在Admin中,profile
函数必须读取第一个参数(创建/编辑/ [用户ID]),然后相应地执行某些操作。 (我们还必须确保没有用户可以称自己为"创建"或者"编辑"。)
我会只使用一个具有功能show,edit和create(或者add)的控制器。容易得多。然后,我们将获得以下URL:
- http:// localhost / profile / show / johndoe
- http:// localhost / profile / edit / johndoe
- http:// localhost / profile / create / johndoe
我找到了所需的解决方案:
http://www.clipmarks.com/clipmark/75D02C9E-3E76-483E-8CCE-30403D891969/
感谢Christian D,我比我更喜欢解决方案。我要去