CodeIgniter Forums
Calling Controller without function and set param - 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: Calling Controller without function and set param (/showthread.php?tid=52765)



Calling Controller without function and set param - El Forum - 06-25-2012

[eluser]Unknown[/eluser]
Hello, i have a controller named as Search, well...
I want call the url like this

http://myurl.com/index.php/search/term_of_search

or

http://myurl.com/search/term_of_search

How i do this?

tks


Calling Controller without function and set param - El Forum - 06-26-2012

[eluser]vitoco[/eluser]
First, to remove "/index.php/" from the url, use mod_rewrite on .htaccess ( search in the wiki or the forums for this ), and to send "search/term_of_search/" to a specific method/function, use custom routes ( see rounting in user guide http://ellislab.com/codeigniter/user-guide/general/routing.html )

If after that, you can't make it work, please reply your specific problem here.

Saludos


Calling Controller without function and set param - El Forum - 06-26-2012

[eluser]uber_n00b[/eluser]
If you want to access the "term_of_search" from your controller function you can do so via:

Code:
function search($term = NULL){
     if ($term){
        //run my search with the passed term
     }
}



Calling Controller without function and set param - El Forum - 06-26-2012

[eluser]PhilTem[/eluser]
Possible solutions are:

1) Reading the CI User's guide observingly from beginning to end and reverse,
or
2) Routing
or
3) _remap()