Simple View Controller for beginners. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: Simple View Controller for beginners. (/showthread.php?tid=1378) |
Simple View Controller for beginners. - dragonabv - 03-04-2015 First thing to post in this forum should be how to create a simple view which is the appearance of your web application. I had tried so many tutorials on Internet for making a MVC and always succeeded but when i try to make my own home page of site my myself i always failed. The only thing that showed up is: "404 Page Not Found The page you requested was not found. " I just want a simple thing. When anyone open www.mywebsite.com my home page will be open. Is this necessary to make a model if there is no database work in needed? Now i tell you what i did myself to make my home page. 1. First of all i made a file 'index.php' in view folder (Simple HTML file). 2. I added a file 'index_controller.php' in controller folder. (see code below) Code: class Index_controller extends CI_Controller{ What more should i do to make my code working?? RE: Simple View Controller for beginners. - Avenirer - 03-05-2015 In the first place, you shouldn't name your controller Index_controller. Never. But if you still want to name it that way, the way to access the controller would be http://localhost/index_controller RE: Simple View Controller for beginners. - Vimal - 03-05-2015 PHP Code: class Index extends CI_Controller{ Go to Yoursite.com/index.php/index or you can set default controller in application/config/route.php RE: Simple View Controller for beginners. - Avenirer - 03-05-2015 My advice is roughly the same. Don't ever create a controller named Index. RE: Simple View Controller for beginners. - dragonabv - 03-05-2015 I know you all maybe masterminds of codeigniter but here i am talking about a person who is a serious beginner. I had find my answer by myself which is "Route.php". This is the main problem in my complete code. No one told me that i have to add a line of code in "config/route.php" to make my link work. Without route.php all the coding is just a waste of time. RE: Simple View Controller for beginners. - mwhitney - 03-05-2015 In application/config/routes.php: PHP Code: $route['default_controller'] = 'home'; // 'welcome' is another popular choice Then add application/controllers/Home.php: PHP Code: <?php The index method in your home controller then becomes available at the following locations (assuming you have rewrite configured properly and index.php removed from your URLs): http://mysite.com/ http://mysite.com/home http://mysite.com/home/index RE: Simple View Controller for beginners. - cartalot - 03-06-2015 the advise to beginners should be - if you can see the CI welcome page - then next work through the tutorial that is in the CI manual. and if you need to work on something quickly, just do it in the welcome controller and there is no other setup required. |