我正在开发一个网站,其中许多页面的内容将从数据库中提取。整个网站在codeigniter中完成。与codeigniter发生冲突
我不想有像www.mywebsite.com/pages/1之类的网址。 相反,我想在输入页面内容时由管理员询问URL名称(FURL)。假设管理员输入FURL为:study-programs/animation 那么路径应显示为www.mywebsity.com/study-programs/animation
有什么建议吗?
我正在开发一个网站,其中许多页面的内容将从数据库中提取。整个网站在codeigniter中完成。与codeigniter发生冲突
我不想有像www.mywebsite.com/pages/1之类的网址。 相反,我想在输入页面内容时由管理员询问URL名称(FURL)。假设管理员输入FURL为:study-programs/animation 那么路径应显示为www.mywebsity.com/study-programs/animation
有什么建议吗?
1)的foreach页面商店页面名称(可以使用uri_title())
2)在路由(的application/config /路线)添加的东西等;
$route['page/(:any)'] = "pages/page_lookup";
3)在页面控制器;
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Pages extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function page_lookup($page) {
// do your database query getting page id where page name = $page
$result = $this->page_model->get_page_by_name($page);
// $result could hold the page html
// if so, then just do
$this->load->view($result);
}
}
欲了解更多详情请查看Codeigniter手册中的examples。
你的意思是用户输入一个分类类别的分类?我不知道为什么用户会输入'study-programs/animation/cgi/smurfs'这样的文本作为路径,您应该让他们选择类别/子类别并为THEM创建路径。 – Jakub