I am having a trouble coming up with the concept of this. My application is stored in http://localhost
(duh) and I have an admin panel, which can be accessed by going to http://localhost/admin
. I have admin panel menu and one of the menus is Manage Pages, accessed by going to http://localhost/admin/manage_pages
. Manage Pages page brings up results from database which have title, description and ID. Now, my question is, if I want to edit lets say the third row's title, how would I do this? would it be http://localhost/admin/manage_pages/3
? But for that case I would have to create a function in controller? I am confused.
问问题
180 次
1 回答
1
如果您喜欢 URI 的格式:localhost/admin/manage_pages/3,那么您唯一缺少的就是为您的控制器函数接受一个变量。在这种情况下,如果没有传递任何内容,我更喜欢设置默认值,并且使用 if else 语句,您有一个方法可以加载指定页面,或者在没有传递任何内容时加载所有页面。
控制器管理员:
public function manage_pages($page_id='')
{
if ($page_id == '')
{ LOAD ALL RESULTS }
else
{ LOAD 1 RESULT }
}
于 2013-02-08T21:35:03.280 回答