Welcome Guest, Not a member yet? Register   Sign In
using of remap function passing it parameter
#1

[eluser]mazzy[/eluser]
In my views I call show function stored in a controller named search. to this function I pass two parameter like this way:

Code:
<?php echo site_url("search/show/param1/param2"); ?>

I would use _remap function in the way I can show as URL :
Code:
/search/show/param1-param2
but I don't know how I can do...some idea?
#2

[eluser]InsiteFX[/eluser]
CodeIgniter User Guide - URI Class

To use _remap it is like this:
./application/config/routes.php
Code:
// ------------------------------------------------------------------------
/**
* DO NOT! REMOVE THIS LINE
* This is for the _remap.
* ------------------------------------------------------------------------
*/
$route['(.*)'] = 'welcome/index/$1';

// --------- -== DO NOT REMOVE! the above line ==- --------

Code:
/**
* index()
*
* index - default method called.
*
* @access public
* @return void
*/
public function index($param1 = NULL, $param2 = NULL)
{
    if ( ! empty($param1))
    {
        // $param1 passed in
    }
    else
    {
        // just index
    }
}

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

/**
* _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();
}
#3

[eluser]mazzy[/eluser]
please can you do an example with data I posted? I didn't understand how pass params. Do I have to put them into params array?
#4

[eluser]InsiteFX[/eluser]
there passed through the url




Theme © iAndrew 2016 - Forum software by © MyBB