CodeIgniter Forums

Full Version: How to use _remap function?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]sunyoupk[/eluser]
I read section of _remap function but I don't understans that yet...
How to use _remap function?
I think _remap function is make to the redirect process simpler. right? Or, Is that possible method overriding like the Java programming?

El Forum

[eluser]Pascal Kriete[/eluser]
It's a way to override the default method routing. Any call to the controller will go through the remap function, no matter what method you specify in the second segment. Make sense?

El Forum

[eluser]sunyoupk[/eluser]
[quote author="inparo" date="1211067163"]Any call to the controller will go through the remap function, no matter what method you specify in the second segment.[/quote]

Thanks~
So.. You mean CodeIgniter system is unconditionally _remap function to called... huh?

El Forum

[eluser]Michael Wales[/eluser]
By default CodeIgniter uses segment to determine the method you want, for example:
domain.com/user/walesmd

Would attempt to use the walesmd() method of the user class.

With _remap - it keeps CodeIgniter from using that logic and does whatever you tell it to. So, you could do something like:
Code:
<?php
  function _remap($username) {
    $this->load->model('users');
    $this->data->user = $this->users->get($username);
    $this->load->view('profile', $this->data);
  }
?>

Personally, URI Routing is a much more graceful way to go about this.

El Forum

[eluser]sunyoupk[/eluser]
[quote author="Michael Wales" date="1211128600"]By default CodeIgniter uses segment to determine the method you want, for example:
domain.com/user/walesmd

Would attempt to use the walesmd() method of the user class.

With _remap - it keeps CodeIgniter from using that logic and does whatever you tell it to. So, you could do something like:
Code:
<?php
  function _remap($username) {
    $this->load->model('users');
    $this->data->user = $this->users->get($username);
    $this->load->view('profile', $this->data);
  }
?>

Personally, URI Routing is a much more graceful way to go about this.[/quote]

Ok, thanks!
Continue my efforts to do~!