![]() |
Getting the URL to work - 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: Getting the URL to work (/showthread.php?tid=6987) |
Getting the URL to work - El Forum - 03-19-2008 [eluser]ptechie[/eluser] Hello all... First of all, I am looking at Code Ignitor for the first time... so please excuse the novice questions and help if you can. I've got a page under the base URL, treatments which works when clicked from the homepage. I found this code, in app/controllers/index.php Quote: Now, there is a link on this page (treatments) that links to <base url>/cancer I've got the cancer.phtml file stored in app/views/index/ (that is where the treatments.phtml is stored) ISSUE: The page <base url>/cancer does not show up, I get a 404. HELP! Thanks Getting the URL to work - El Forum - 03-19-2008 [eluser]zimco[/eluser] Taking a wild stab at your problem, i'm a newbie too, but is there any reason why you are using the .phtml extension for your files rather than the good-old .php file extension? I'd try changing that first.... Getting the URL to work - El Forum - 03-19-2008 [eluser]ptechie[/eluser] Well, that's how the application has been setup. With the reading that I did, I don't think that would cause the issue... also all the other pages that are working fine are also .phtml. Thanks Getting the URL to work - El Forum - 03-19-2008 [eluser]Matthew Lanham[/eluser] You need to add the function cancer() into your controllers from what i can see, CI will not automatically pick up new views... Getting the URL to work - El Forum - 03-19-2008 [eluser]ptechie[/eluser] I should have mentioned, I have done this Quote: function cancer() Thanks Getting the URL to work - El Forum - 03-19-2008 [eluser]zimco[/eluser] Well if .phtml works for you then the only other thing that looks different to me is the $this->data in the load view statement. I've had good luck doing it like: Code: $this->load->view('some_view', $data); where $data is an array or an object. Getting the URL to work - El Forum - 03-19-2008 [eluser]ptechie[/eluser] zimco - I tried that and it didn't help. Also, like I mentioned that the other pages are working fine. Hope, someone could explain how this works... what are the elements I need to make the pages to show up? Getting the URL to work - El Forum - 03-19-2008 [eluser]Pascal Kriete[/eluser] Usually it's quite simple, but it sounds like the application your working on has been changed a bit. The normal way: Take all the variables you need in your view and put them in an associative array, such as: Code: $view_vars = array('test' => $var, 'test2' => 'cool'); Then load your view using: Code: $this->load->view('view', $view_vars); If you don't need any variables in your view you can omit that parameter. The variables are extracted, so that in your view you now have access to $test and $test2. I would suggest you find the template function and figure out what it does differently. Apart from using a different extension. Getting the URL to work - El Forum - 03-19-2008 [eluser]ptechie[/eluser] Thanks to everyone who responded... I found that there is a file (./app/config/routes.php), where I needed to enter Quote:$route['cancer'] = "index/cancer"; Thank you once again. |