CodeIgniter Forums

Full Version: parameter for default controller
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]aryan_[/eluser]
I have created a default controller 'Pages'. How do I pass parameter to index of this controller?

i.e. http://example.com/param1/param2

I need this only for default controller.

Please help. Thanks!

El Forum

[eluser]Isern Palaus[/eluser]
[quote author="aryan_" date="1259077368"]I have created a default controller 'Pages'. How do I pass parameter to index of this controller?

i.e. http://example.com/param1/param2

I need this only for default controller.

Please help. Thanks![/quote]

Hi,

you can use:

$param1 = $this->uri->segment(1);
$param2 = $this->uri->segment(2);

in your index() function.

Wish it helps!
Isern

El Forum

[eluser]aryan_[/eluser]
Quote:you can use:

$param1 = $this->uri->segment(1);
$param2 = $this->uri->segment(2);

in your index() function.

Wish it helps!
Isern

But, It'll look for controller for segment1 and function for segment2!

I've got a little success using route:

$route['pages/:any'] = "pages/index/$1";

I can remove 'pages/' to achieve this, but what about other controllers?

El Forum

[eluser]jedd[/eluser]
You are allowed, nay encouraged, to use the [url="/forums/search/"]search feature[/url] within the forums.

This was posted and answered (probably for the umpteenth time) just ten days ago in the thread titled [url="/forums/viewthread/135187/"]Parameters to Controller index()[/url] (alarmingly close to parameter for default controller, eh?).