New to CodeIgniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: New to CodeIgniter (/showthread.php?tid=54110) |
New to CodeIgniter - El Forum - 08-23-2012 [eluser]davy_yg[/eluser] Hello, I am new to codeigniter, I am following code igniter tutorial: Introduction: Static Pages Where should I add this codes: public function view($page = 'home') { if ( ! file_exists('application/views/pages/'.$page.'.php')) { // Whoops, we don't have a page for that! show_404(); } $data['title'] = ucfirst($page); // Capitalize the first letter $this->load->view('templates/header', $data); $this->load->view('pages/'.$page, $data); $this->load->view('templates/footer', $data); } I don't really understand the instruction. New to CodeIgniter - El Forum - 08-23-2012 [eluser]valuk[/eluser] In controller. New to CodeIgniter - El Forum - 08-23-2012 [eluser]davy_yg[/eluser] in which file? New to CodeIgniter - El Forum - 08-23-2012 [eluser]ppwalks[/eluser] Probably welcome.php, did you change default controller? New to CodeIgniter - El Forum - 08-23-2012 [eluser]davy_yg[/eluser] ok, I just add them to welcome.php Now I am trying to view: localhost/CodeIgniter212/index.php/pages/view/about I suppose to see the about page, yet I do not. I suppose to see the header and footer. I only see a blank page. New to CodeIgniter - El Forum - 08-23-2012 [eluser]ppwalks[/eluser] Load one view like your index, then load header and footer in the index, does that make sense? Have you created the views in your views folder? Blank page says no view available! Comment out the views and simply echo something to check it loads ok New to CodeIgniter - El Forum - 08-23-2012 [eluser]davy_yg[/eluser] you mean creating views.php in views folder? I have pages folder in views folder which consist of: about and home I also have templates folder in views folder which consist of: footer and header New to CodeIgniter - El Forum - 08-23-2012 [eluser]ppwalks[/eluser] Can Recommend a book for you to work through "Wrox" "Professional Codeigniter", it will walk you through all the issues you have, seriously I think you need a good book! New to CodeIgniter - El Forum - 08-23-2012 [eluser]davy_yg[/eluser] Okay, I just get the ebook. There is too much information in it. I am trying to get a hold of the basic from the CodeIgniter Tutorial / User Guide. Maybe it's faster. New to CodeIgniter - El Forum - 08-23-2012 [eluser]Rolly1971[/eluser] ok starting with your view files. in folder: application/views create the two folders: templates, and pages in templates folder create or put the view files: header.php, footer.php in pages folder put: home.php (as an example) in application/controllers create a file names: pages.php in this file put the following code: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); that should do the trick |