User Guide (Static Page) Documentation Clarification Please - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9) +--- Thread: User Guide (Static Page) Documentation Clarification Please (/showthread.php?tid=68968) |
User Guide (Static Page) Documentation Clarification Please - kuler - 09-21-2017 Hello everyone, While I have been using PHP for quite some time, I am totally new to CodeIgniter so please forgive my ignorance. I have downloaded and installed CodeIgniter and am running it on MAMP. I am working my way through the documentation and am following the instructions for a static page. I have come to this section: https://codeigniter.com/user_guide/tutorial/static_pages.html#adding-logic-to-the-controller It reads (3rd paragraph): Quote:In order to load those pages, you’ll have to check whether the requested page actually exists: It then provides some sample code: Code: public function view($page = 'home') My question is, WHERE does that code go? Does it go in the applications/controllers/Pages.php file? The instructions don't really tell you where that is supposed to go. Again, I know that this is probably really stupid question, but like I said, I am spanking new to CodeIgniter ... however, feel free to make fun of me RE: User Guide (Static Page) Documentation Clarification Please - rtenny - 09-21-2017 It does state it in the tutorial "Adding logic to the controller" ..... In order to load those pages, you’ll have to check whether the requested page actually exists: The view function might already exist in your controller then you just add the if contruct to show the 404 error I hope that helps. RE: User Guide (Static Page) Documentation Clarification Please - donpwinston - 09-21-2017 Yes, it goes in the applications/controllers/Pages.php file. See the Routing section to se how it is invoked. RE: User Guide (Static Page) Documentation Clarification Please - kuler - 09-21-2017 Thank (both of you) for your kind responses ... when I add it to the controller (Pages.php) then I get the following error when trying to view them Code: An uncaught Exception was encountered So, not sure why that would be the case, it is supposed to work ... RE: User Guide (Static Page) Documentation Clarification Please - rtenny - 09-22-2017 Look at line number 9 there seem to be something missing. Either a semicolon or } or ) Most likey you did not select the entire code and pasted only parts of it. RE: User Guide (Static Page) Documentation Clarification Please - Raymien - 09-28-2017 Hello Kuler, I rember going though this as well, and thought it looked odd, but you have to remember that the provided code below Quote:In order to load those pages, you’ll have to check whether the requested page actually exists:is supposed to replace the code currently in the Pages controller: Code: public function view($page = 'home') So the controller goes from: Code: <?php to: Code: <?php :-) |