• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.