• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use _remap function?

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

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

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

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

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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