Problem with URL doing tutorial |
[eluser]SimonLove2009[/eluser]
Hi I've downloaded CI and installed it on my server. I'm following along with the tutorial:— 1. I've created pages.php, added the view() function and put it in the directory;controllers. 2. I've created to templates(header.php & footer.php) and put them in views/templates. 3. I've created a pages directory and added home.php & about.php to them with some text added. The tutorial now says—'Now, when the page does exist, it is loaded, including the header and footer, and displayed to the user.' My question is this—How should I get the page to load? I'm using MAMP for my php testing server. I've currently set it to load CI which it does perfectly. However, I'm confused as to what URL or path I should use instead of — http://codeigniter:8888/ to test the application I'm building. Whenever I put any of the file paths that would seem logical it says I don't have permission or file not found. Do I have to alter/modify the routes.php file in config directory? Kind regards Simon
[eluser]PhilTem[/eluser]
A controller called pages will add a pages segment to your URI thus resulting in Code: www.example.com/index.php/pages Now, if you don't add a index-method to your controller it will show a 404 error-page because that's the way CI is designed to work: If there is no second segment it will look for a method called index. In your case, you have a method called view which can similarly to above be translated to a second URI segment called view so your URL will look like this Code: www.example.com/index.php/pages/view Go to this page and you should see your header, content and footer loaded.
[eluser]SimonLove2009[/eluser]
Hi Thanks for responding to my post. In my original post I asked should I alter the the routes.php file and you didn't mention that. At the end of the tutorial sure enough it says, I should alter the routes.php file... What I want to know is the following—why the tutorial tells me to create a directory called pages(containing home.php & about.php) inside the views directory which would have a path of views/pages and then about two paragraphs later the tutorial is saying I should point my brower to pages/view and index.php/pages/view/about—WHAT IS GOING ON??? The pages and views directory order has been completely REVERSED!!! Is this deliberate? What does it mean? This tutorial is ridiculous. It reminds me of one of those bicycles at a fairground with eccentric wheels and handlebars that turn the opposite direction to the way the rider wants to go... This tutorial is appallingly bad to the point of being comedy. Do people ever read this tutorial and get somewhere with it? Maybe I should go an practice with a fairground bike first, or use my computer with a blindfold??? Can somebody explain???
[eluser]Aken[/eluser]
Have you read any other parts of the user guide besides the tutorial? Because the tutorial is more of a "do this after familiarizing yourself a bit" kind of tutorial, not a full beginner step-by-step kind of thing. Definitely read through the "General Topics" column in the guide. Your views folder structure has nothing to do with the URL. Your controllers are what the URLs are mapped to. |
Welcome Guest, Not a member yet? Register Sign In |