Welcome Guest, Not a member yet? Register   Sign In
404 issue with existing function
#4

[eluser]jsuissa[/eluser]
Thanks -- tried changing the route to:
$route[‘item/(:any)/(:num)’] = ‘items/details/$2’;

and also tried switching order:
$route['item/(:any)'] = 'items/details';
$route['item'] = 'items';

Still keep getting 404 error. I put a die() in the details function just to eliminate something inside the function as the problem and it never runs so it's not even getting to the function.

Below is the beginning of the controller if that helps:

Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

ini_set('display_errors',1);
error_reporting(E_ALL);


class Items extends CI_Controller {

public function __construct()
{
  parent::__construct();
  $this->load->model( 'items_model', 'Item' );
        $data['site_name'] = $this->config->item( 'site_name' );
        $this->load->vars( $data );
}

    public function index() {
        $data['page_title'] = 'All Items';
  $data['items'] = $this->Item->get_all();
  $this->load->view( 'templates/header', $data );
  $this->load->view( 'items/index', $data );
  $this->load->view( 'templates/footer', $data );
    }

public function details() { // ROUTE: item/{name}/{id}
  die("TEST");
  $id = $this->uri->segment( 3 );
  $item = $this->Item->get( $id );
  
  if ( ! $item ) {
    $this->session->set_flashdata( 'error', 'Item not found.' );
    redirect(site_url('items'));
  }
  
  $data['page_title'] = $item->name;
  $data['item'] = $item;
  
  $this->load->view( 'templates/header', $data );
  $this->load->view( 'items/details', $data );
  $this->load->view( 'templates/footer', $data );
}


Messages In This Thread
404 issue with existing function - by El Forum - 02-26-2012, 08:10 PM
404 issue with existing function - by El Forum - 02-26-2012, 08:40 PM
404 issue with existing function - by El Forum - 02-26-2012, 09:17 PM
404 issue with existing function - by El Forum - 02-27-2012, 10:03 AM
404 issue with existing function - by El Forum - 02-27-2012, 10:40 AM
404 issue with existing function - by El Forum - 02-27-2012, 10:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB