CodeIgniter Forums
using of remap function passing it parameter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: using of remap function passing it parameter (/showthread.php?tid=49435)



using of remap function passing it parameter - El Forum - 02-19-2012

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


using of remap function passing it parameter - El Forum - 02-19-2012

[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();
}



using of remap function passing it parameter - El Forum - 02-19-2012

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


using of remap function passing it parameter - El Forum - 02-19-2012

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