Welcome Guest, Not a member yet? Register   Sign In
Routing with dynamic Event ID in URL for event managment system
#8

[eluser]PhilTem[/eluser]
Okay, some really quick and dirty code for the lazy:

With Routing:
Code:
$route['event/(:any)/registration'] = 'event/registration/$1';
$route['event/(:any)/join'] = 'event/join/$1';
in the controller
Code:
class Event extends CI_Controller {
  function registration($event_id)
  {
    // do registration stuff here
  }
  
  function join($event_id)
  {
    // do join stuff here
  }
}

Or, with _remap, there's no need for routing!
Code:
class Event extends CI_Controller {
  function _remap()
  {
    $event_id = $this->uri->segment(2);
    
    if ( $method = $this->uri->segment(3) )
    {
      return call_user_func_array(array(&$this, $method), $event_id);
    }
    else
    {
      // Do whatever you want to do when the URI is just like
      // www.example.com/event/EVENT_ID
    }
  }
  
    function registration($event_id)
  {
    // do registration stuff here
  }
  
  function join($event_id)
  {
    // do join stuff here
  }
}


Messages In This Thread
Routing with dynamic Event ID in URL for event managment system - by El Forum - 09-08-2012, 10:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB