Welcome Guest, Not a member yet? Register   Sign In
How to handle URL
#1

[eluser]DaTran[/eluser]
How do i get www.example.com/auction/1 to work in my controller?

1 = id number

I've tried

Code:
class Auction extends Controller
{

function index()
    {
        if($this->uri->segment(2))
        {
            echo 'This works';
        }
    }
}

but nothing comes out.
#2

[eluser]vitoco[/eluser]
segment 1 is the controller
segment 2 is the function
segment 3 is the first param ...
segment 4 is the second param ...
... and so on

also i think that you need the controller constructor

Saludos
#3

[eluser]mi6crazyheart[/eluser]
Change u'r url to this : www.example.com/auction/index/1
Try this...
Code:
class Auction extends Controller
{

function index()
    {
        if($this->uri->segment(3))
        {
            echo 'This works';
        }
    }
}
#4

[eluser]Stockhausen[/eluser]
There is two example :
Code:
class Auction extends Controller
{

function index($id = false)
    {
           if($id) {
                       echo 'This works and id is : ' $id;
           }
    }
}
Code:
www.example.com/auction/index/1

or if you have just one function in this controller you may use system/application/config/route.php rewriting rule
Code:
$route[auction/(:any)] = 'auction/index/$1';
but this way is not a real solution, you must conform to the syntax controller/function/firstparameter/secondparameter ....

sorry for my engliish writing !
#5

[eluser]Colin Williams[/eluser]
http://ellislab.com/forums/viewthread/135187/#668213
#6

[eluser]DaTran[/eluser]
[quote author="Colin Williams" date="1275388139"]http://ellislab.com/forums/viewthread/135187/#668213[/quote]

Thank you, thank you, thank you, thank you!




Theme © iAndrew 2016 - Forum software by © MyBB