Welcome Guest, Not a member yet? Register   Sign In
Default controller always called
#1

[eluser]furnak[/eluser]
Having an issue where the default controllers as set in routes is always being called, is this a designed behaviour? Because I'd really rather it didn't!
#2

[eluser]mddd[/eluser]
The default controller should only be called if you don't specify a controller (e.g. when you specify only the domain name).
If you feel there is something wrong, post your routes so we can check!
#3

[eluser]furnak[/eluser]
Code:
$route['default_controller'] = "Home";
$route['scaffolding_trigger'] = "";

$route['all/searc(:any)'] = "search/all_products/search";
$route['parking/searc(:any)'] = "search/parking_search/search";
$route['car-hire/searc(:any)'] = "search/car_hire_search/search";
$route['transfers/searc(:any)'] = "search/transfers_search/search";
$route['insurance/searc(:any)'] = "search/insurance_search/search";
$route['airport-lounge/searc(:any)'] = "search/lounge_search/search";

/**
*
*/
$route['all/(:any)'] = "all/landing";
$route['airport-parking/(:any)'] = "parking/landing";
$route['car-hire/(:any)'] = "car_hire/landing";
$route['transfers/(:any)'] = "transfers/landing";
$route['insurance/(:any)'] = "insurance/landing";
$route['lounges/(:any)'] = "lounges/landing";

/* Basket */
$route['basket'] = "basket/basket";
$route['basket/(:any)'] = "basket/basket/$1";
$route['basket/delete'] = "basket/basket/delete_basket";
/* Confirmation */
$route['checkou(:any)'] = "basket/checkout/user_checkout";
$route['checkout/validate'] = "basket/checkout/validateCheckout";
$route['checkout/voucher'] = "basket/checkout/voucher";            
/*Payment*/
$route['confirmatio(:any)'] = "basket/confirmation/confimation";
$route['complete(:any)'] = "basket/confirmation/completed";          

/* Re-routes for old landings */
$route['airport-parkin(:any)'] = "parking/landing";
$route['car-hir(:any)'] = "car_hire/landing";
$route['airport-transfer(:any)'] = "transfers/landing";
$route['travel-insuranc(:any)'] = "insurance/landing";
$route['airport-loung(:any)'] = "lounges/landing";  
/* End of file routes.php */
/* Location: ./system/application/config/routes.php */

The above are my current routes,

Code:
class Home extends MY_Controller {
        
    function index()
    {
        $data['page_title'] = 'home page';
        $data['page'] = 'content/home_page';
        $this->load->view('page', $data);
    }
    
}

<?php  
class MY_Controller extends Controller {
    
    function MY_Controller()
    {
        parent::Controller();
        $this->load->model('Session_manager');
        $this->load->model('Content_manager');  
        $this->Session_manager->check_session();
    }

}

However when debugging in PHPed, what I've notice is that even though the site will render pages and carry out everything fine the index function in Home is always called
#4

[eluser]mddd[/eluser]
Given your routes, if any of those routes is matched, the home controller should not be called but the controller that the route points to.

I do see a few errors, like this:
Code:
* Basket */
$route['basket'] = "basket/basket";
$route['basket/(:any)'] = "basket/basket/$1";
$route['basket/delete'] = "basket/basket/delete_basket";
In this case, basket/delete is never matched because if the url is /basket/delete, the second rule will match! So the third will never take effect.
#5

[eluser]furnak[/eluser]
I've attached a image that contains snippets of screen shots showing the call stack if that's any help. That show the index page being called twice,




Theme © iAndrew 2016 - Forum software by © MyBB