User Guide (Static Page) Documentation Clarification Please |
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/tutor...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
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.
On the package it said needs Windows 7 or better. So I installed Linux.
Yes, it goes in the applications/controllers/Pages.php file.
See the Routing section to se how it is invoked.
Simpler is always better
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 ...
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.
On the package it said needs Windows 7 or better. So I installed Linux.
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 :-) |
Welcome Guest, Not a member yet? Register Sign In |