Welcome Guest, Not a member yet? Register   Sign In
help with $_GET in CI
#1

[eluser]look66[/eluser]
Hi I do not speak English, I am Brazilian, I speak English very bad.
My doubt is:

I was wondering if you can send the value of a variable after the first bar, example:

www.example.com.br/var1
www.example.com.br/var2

I wanted to send this variable for main page of the site, but the URL stay with this format

base url () + var

Anyone have any tips?
Thank you!
#2

[eluser]Rowan Wilson[/eluser]
check out the URI class: http://ellislab.com/codeigniter/user-gui...s/uri.html

I think that's what you are referring to.
#3

[eluser]look66[/eluser]
[quote author="rowstu" date="1356093092"]check out the URI class: http://ellislab.com/codeigniter/user-gui...s/uri.html

I think that's what you are referring to.[/quote]

Thanks for the reply

Currently I am passing the variable as follows:

http://www.example.com/Home/index/var1

I want the url to this view

http://www.example.com/var1

sending the 'var1' to the 'index' method of the controller 'Home'
#4

[eluser]PhilTem[/eluser]
I guess, routing is what you want to implement
#5

[eluser]InsiteFX[/eluser]
index method:
Code:
// --------------------------------------------------------------------

/**
  * index()
  *
  * index - default method called.
  *
  * @access public
  * @return void
  */
public function index($param = NULL)
{

}

Add this to your Controller:
Code:
// --------------------------------------------------------------------

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

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

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

[eluser]look66[/eluser]
@ InsiteFX thank you for your reply!
Your reply was exactly what I needed!

I only have one more doubt:
what function this 'if' you posted

[code]
if (method_exists ($ this, $ method))
{
return call_user_func_array (array ($ this, $ method), $ params);
}

show_404 ();
[/ code]
#7

[eluser]InsiteFX[/eluser]
CodeIgniter Users Guide - Controllers - Remapping Function Calls




Theme © iAndrew 2016 - Forum software by © MyBB