Strange problem with $this->load->view - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Strange problem with $this->load->view (/showthread.php?tid=4472) Pages:
1
2
|
Strange problem with $this->load->view - El Forum - 11-28-2007 [eluser]coolfactor[/eluser] Please paste your entire Articles index() function. Also, do you have *any* redirects in that controller, anywhere? Strange problem with $this->load->view - El Forum - 11-29-2007 [eluser]Dionysius[/eluser] [quote author="coolfactor" date="1196329158"]Please paste your entire Articles index() function. Also, do you have *any* redirects in that controller, anywhere?[/quote] Code: function index() There are 3 redirect() calls. But they are not called when I go to URL articles/<number> Strange problem with $this->load->view - El Forum - 11-29-2007 [eluser]coolfactor[/eluser] First off, the function itself should be written without making any assumptions about custom routes. That means this line: Code: $sec_id = (int)$this->uri->segment(2); ...should be changed to: Code: $sec_id = (int)$this->uri->rsegment(3); // rewritten-segment ...or get the parameters from the function arguments: Code: function index($sec_id = 0, $start = 0) { Both ways will isolate the custom routing from the function definition. --- I suspect the problem is happening with this redirect: Code: if (!$data['articles']) redirect(''); Try adding this code before that line to see exactly what is in the $data array: Code: var_dump($data); You might find that $data['articles'] is evaluating to FALSE for some reason. Strange problem with $this->load->view - El Forum - 11-29-2007 [eluser]Dionysius[/eluser] [quote author="coolfactor" date="1196348953"]First off, the function itself should be written without making any assumptions about custom routes. That means this line: Code: $sec_id = (int)$this->uri->segment(2); ...should be changed to: Code: $sec_id = (int)$this->uri->rsegment(3); // rewritten-segment ...or get the parameters from the function arguments: Code: function index($sec_id = 0, $start = 0) { Both ways will isolate the custom routing from the function definition. [/quote] Done. But it didn't change anything. [quote author="coolfactor" date="1196348953"] I suspect the problem is happening with this redirect: Code: if (!$data['articles']) redirect(''); I did it yesterday. See this thread from the beginning. $data['articles'] is not empty when $sec_id == 1 or 2. Strange problem with $this->load->view - El Forum - 01-31-2008 [eluser]Dionysius[/eluser] I found the problem! It was in method called 'view'. In PHP5 controller may has method with such name, but in PHP4 it has strange behaviour. |