CodeIgniter Forums
How to use _remap function? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to use _remap function? (/showthread.php?tid=8428)



How to use _remap function? - El Forum - 05-17-2008

[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?


How to use _remap function? - El Forum - 05-17-2008

[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?


How to use _remap function? - El Forum - 05-18-2008

[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?


How to use _remap function? - El Forum - 05-18-2008

[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.


How to use _remap function? - El Forum - 05-18-2008

[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~!