Welcome Guest, Not a member yet? Register   Sign In
How to display a users personal page from URL - mysite/username
#18

[eluser]benners[/eluser]
Done some more testing and it seems it will probably work with the following setup but it means I have to put 2 routes for each controller I have. Isn't there a better way that this? It's not exactly automated.

Main controller - main.php
Code:
public function _remap($method, $params = array())
{
if (method_exists($this, $method)) {
  return call_user_func_array(array($this, $method), $params);
} else {
  $user_info = $this->membership_model->get_member($method);
  if(count($user_info) > 0){
   // Display the user with the profile page.
   $data['user_info'] = $user_info;
   $data['main_content'] = 'profile_view';
   $this->load->view('includes/template', $data);  
  } else {
   show_404();
  }
}
}

routes.php
Code:
$route['default_controller'] = 'main';
$route['login/(:any)'] = 'login/$1';
$route['login'] = 'login';
$route['contact'] = 'contact';
... // All my other pages
$route['(.*)'] = 'main/$1'; // sends all other requests to main.php for remapping


Messages In This Thread
How to display a users personal page from URL - mysite/username - by El Forum - 02-29-2012, 03:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB