c_pattle Posted December 6, 2011 Share Posted December 6, 2011 I have a form that when submitted goes to "products/search/" This is the method that it directs too. function search($searchCat = NULL, $searchString = NULL) { if($this->input->post('searchSubmit')) { $searchCat = $this->input->post('searchCat'); $searchString = $this->input->post('searchString'); } //Get the base URL and assign it to a variable $aData['base_url'] = base_url(); //Run the getProductsBySearch function in the product model and pass two parameters //This returns the search results $aData['query'] = $this->ProductModel->GetProductsBySearch($searchCat, $searchString); //Run the getBestSellers function in the product model //This returns the top 3 best selling products $aData['bestsellers'] = $this->ProductModel->getBestSellers(); //Pass the best sellers data to the best sellers view and save it in a variable $aData['rightSidebar'] = $this->load->view('products/bestsellers', $aData, true); //Get breadcrumb trail and assign it to a variables $aData['breadcrumbs'] = create_breadcrumb(); //Pass the data to the left sidebar view and save it in a variable $aData['leftSidebar'] = $this->load->view('products/leftsidebar', $aData, true); //Load the cart library //$this->load->library('cart'); //Get the contents, total amount and total items of the cart $aData['cart'] = $this->cart->contents(); $aData['cart_total'] = $this->cart->total(); $aData['total_items'] = $this->cart->total_items(); //Load the layout library $this->load->library('layout'); //Get the header and footer and save them in variables $aData['header'] = $this->layout->pageHeader($aData); $aData['footer'] = $this->layout->pageFooter(); //If more than one row is returned load multiple product view otherwise load single view if ($aData['query']->num_rows() > 1) { $aData['content'] = $this->load->view('products/products_layout', $aData, true); } else { $aData['content'] = $this->load->view('products/product_layout', $aData, true); } //Load the three column layout view $this->load->view('layout/main/three_col', $aData); } Then in my views file I have the following lines. $route['products/search/'] = "products/search/"; $route['products/search/(:any)/(:any)'] = "products/search/$1/$2"; It works fine when the URL is something like "products/search/all/03241/" but not when it's just "products/search". Does anyone know what I'm doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/252572-codeigniter-routes-problem/ Share on other sites More sharing options...
jotorres1 Posted December 7, 2011 Share Posted December 7, 2011 Hi c_pattle, Then in my views file I have the following lines. $route['products/search/'] = "products/search/"; $route['products/search/(:any)/(:any)'] = "products/search/$1/$2"; It works fine when the URL is something like "products/search/all/03241/" but not when it's just "products/search". Does anyone know what I'm doing wrong? This should not be in your view file. If this is in your view file, then it's referring to a local variable, not the config file variable. I would recommend using _remap. I will not explain what it is here in this post, but if you give me until tomorow, my post will publish. It will teach you to use it, and I have a very simple example in which you will be able to modify it for your needs. I regret not posting it today, as I had no time to finish it. I will come back once it's published. (The latest will be by tomorrow) If you can't wait that long, then go ahead and google _remap. Quote Link to comment https://forums.phpfreaks.com/topic/252572-codeigniter-routes-problem/#findComment-1295120 Share on other sites More sharing options...
jotorres1 Posted December 7, 2011 Share Posted December 7, 2011 Hi c_pattle, Here is what I have promised: http://www.jotorres.com/en/2011/12/remapping-function-calls-in-codeigniter/ Hope you enjoy and understand. Quote Link to comment https://forums.phpfreaks.com/topic/252572-codeigniter-routes-problem/#findComment-1295495 Share on other sites More sharing options...
reneeshtk Posted March 22, 2012 Share Posted March 22, 2012 I was also the same problem and I fixed it by a small change in URI.php page in the system/core In my checking I feel like it was due to a small bug in codeigniter. Anyway I am not an expert. Anyway I fixed it. I was a problem with codeigniter url rewriting. I have to go to www.abc.com/catalog/product/4354 when using the url www.abc.com/samsung_galaxy_y I have explained it in my blog myphplibrary.blogspot.in http://myphplibrary.blogspot.in/2012/03/codeigniter-routing-issue-fixation-url.html Quote Link to comment https://forums.phpfreaks.com/topic/252572-codeigniter-routes-problem/#findComment-1330128 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.