Welcome Guest, Not a member yet? Register   Sign In
Not sure how to use remap feature
#1

[eluser]Emkay[/eluser]
I have a controller called "category"

However, instead of the next uri segment being a function, I want it to be a parameter to the default index function of the controller.

How do I do this?

E.g.

Code:
www.website.com/category/books

should remap to

Code:
www.website.com/category/index/books

I don't think using routes is the best way to do this? There must be some better?
#2

[eluser]InsiteFX[/eluser]
Code:
public function index($params = array())
{
    // Your code goes here!
}

// --------------------------------------------------------------------

/**
* _remap()
*
* Remaps the URL segments.
*
* @access    private
* @param    string
* @param    array
* @return    mixed
*/
public function _remap($method, $params = array())
{
    if (method_exists($this, $method))
    {
        return call_user_func_array(array($this, $method), $params);
    }

    show_404();
}

// application/config/routes.php
$route['category/(:any)'] = 'category/index/$1';

InsiteFX
#3

[eluser]Emkay[/eluser]
Thanks a bunch!! Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB