Please help with $_GET['page']... - 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: Please help with $_GET['page']... (/showthread.php?tid=37856) |
Please help with $_GET['page']... - El Forum - 01-22-2011 [eluser]BoyBlue[/eluser] I have this code working on a project outside of CI (I had to replace href with *stuff* to get this to post) Code in my *View* Page: <ul class="navbar"> <li class="button"><a stuff="index.php">Home</a></li> <li class="button"><a stuff="index.php?page=BlogPosts">Blog Posts</a></li> <li class="button"><a stuff="index.php?page=Photos">Photos</a></li> <li class="button"><a stuff="index.php?page=Issues">Issues</a></li> </ul> *Controller* page Code: if($_GET['page'] == "BlogPosts"){ include("views/blogposts.php"); }else if($_GET['page'] == "Photos"){ include("views/photos.php"); }else if($_GET['page'] == "Issues"){ include("views/issues.php"); }else{ include("views/home.php"); } ****Now here is My failed attempt at CI:**** View Code: <ul class="navbar"> <li class="button"><a stuff="index.php">Home</a></li> <li class="button"><a stuff="index.php?page=BlogPosts">Blog Posts</a></li> <li class="button"><a stuff="index.php?page=Photos">Photos</a></li> <li class="button"><a stuff="index.php?page=Issues">Issues</a></li> </ul> Controller Code: if ($this->input->get('page') == 'BlogPosts'){ $this->load->view('view_blog_posts'); } elseif ($this->input->get('page') == 'Photos'){ $this->load->view('view_photos'); } elseif ($this->input->get('page') == 'Issues'){ $this->load->view('view_issues'); } else{ $this->load->view('view_home'); } The error that I'm getting is *404 Page Not found*. What am I doing wrong? Also, is there a better way to do this inside CI? thx, Ryan Please help with $_GET['page']... - El Forum - 01-23-2011 [eluser]umefarooq[/eluser] First CI is not supporting GET for security reason for this you have to use URI class will help you. in your controller Code: $view = 'view_home'; no need to use more if conditions if you are using small letter then no need to use strtolower while joining string Please read doc URI Class http://ellislab.com/codeigniter/user-guide/libraries/uri.html Input class http://ellislab.com/codeigniter/user-guide/libraries/input.html Please help with $_GET['page']... - El Forum - 01-23-2011 [eluser]InsiteFX[/eluser] CI 2.0 has $_get. InsiteFX |