Welcome Guest, Not a member yet? Register   Sign In
_remap not working with more than one segment
#1

[eluser]chrisnharvey[/eluser]
Hello,

I have used some code that I found on the forums that allows rerouting the method to the index function.

Here is the code:

Code:
function _remap($method)
{
   $param_offset = 2;

   // Default to index
   if ( ! method_exists($this, $method))
   {
     // We need one more param
     $param_offset = 1;
     $method = 'index';
   }

   // Since all we get is $method, load up everything else in the URI
   $params = array_slice($this->uri->rsegment_array(), $param_offset);

   // Call the determined method with all params
   return call_user_func_array(array($this, $method), $params);
}

I added an echo to check that it is working and it only echoes on the index page. My project is a movie review website and I wanted to remap the movie id to the index function. E.g. http://example.com/movie/281

My directory structure is as follows:

controllers
=== movie
======main.php

I also have an extended MY_Router.php file but I have removed this for testing purposes and I don't think this is the issue.

Any ideas on how I might be able to solve this problem?

Thanks for your time and I apologise for not being able to explain this in such simple terms.

Thanks again,

- Chris




Theme © iAndrew 2016 - Forum software by © MyBB