Welcome Guest, Not a member yet? Register   Sign In
Codeigniter User Guide, Controllers: default_method()?
#1

[eluser]Unknown[/eluser]
Hello Codeigniter experts!

I'd be grateful to clarification of something on the controllers page of the user guide:

http://ellislab.com/codeigniter/user-gui...llers.html

The section "Remapping function calls" contains the following snippet:

Code:
public function _remap($method)
{
    if ($method == 'some_method')
    {
        $this->$method();
    }
    else
    {
        $this->default_method();
    }
}

I tried to implement it like this:

Code:
public function _remap($method='comments')
{
  if ($method == 'news')
  {
   $this->$method();
  }
  else
  {
   $this->default_method();
  }
}

Needless to say, I received an error: Call to undefined method Blog::default_method().

What should I do differently?

Thanks in advance!
#2

[eluser]InsiteFX[/eluser]
The CI_Controller default method is the index method everything will pass through the index method.

_remap will proccess any parameters that are passed through the index method.

Code:
public function index($prams)
{
    // your code here
}

$prams would be passed to the _remap method.

This is usefull for like a users profile. http://www.your.com/username






Theme © iAndrew 2016 - Forum software by © MyBB