0
嘗試將網頁路由爲website.com/'schoolname'。如果有一個名字相同的控制器,它會通過它..否則它會檢查數據庫中是否有這樣的學校名稱,如果有一個它將會進入它的檔案頁面。如果沒有檔案,它將返回一個404頁。如何在codeigniter w/0 db中執行動態路由db
代碼
路線
$wind = array("app.php","assignment.php","backup.php","book.php","bulkimport.php","category.php","classes.php","conversation.php","dashboard.php","eattendance.php","event.php","exam.php","examschedule.php","exceptionpage.php","expense.php","feetypes.php","grade.php","hmember.php","holiday.php", "hostel.php","index.html" , "install.php","invoice.php" , "issue.php" ,"language.php", "lmember.php" , "mailandsms.php" ,"mailandsmstemplate.php", "mark.php" , "markpercentage.php", "media.php", "menu.php", "migration.php" ,"notice.php" , "parents.php", "paymenthistory.php" , "paymentsettings.php" , "permission.php", "profile.php", "promotion.php" , "report.php" , "reset.php", "resetpassword.php" , "routine.php" , "sattendance.php", "school.php" ,"schoolyear.php" ,"section.php", "setting.php" , "signin.php" , "signup.php" , "smssettings.php" ,"student.php" , "subject.php" , "syllabus.php" , "systemadmin.php", "tattendance.php", "teacher.php" ,"tmember.php" ,"transport.php" , "update.php" , "user.php" , "usertype.php" , "visitorinfo.php");
foreach ($wind as $win)
{
$controllers[] = $win;
}
$id = $this->uri->segment(1);
if (in_array($id.'.php', $controllers)){
$route[$id] = $id;
}else{
$route[$id] = 'school/index/'.$id;
}
控制器
public function index($id = null)
{
$a = $this->systemadmin_m->get_fnall($id);
if($a != null){
$this->load->view('front/header');
$this->load->view('front/includes');
$this->load->view('front/sindex');
$this->load->view('front/footer');
}else{
$this->load->view('errors/notfound');
}
}
對不起,這是在foreach我從某處複製該部分的錯誤。它完美的作品.. –