Welcome Guest, Not a member yet? Register   Sign In
url and defualt function in controller
#1

[eluser]italoc[/eluser]
i need that controller work in this way

url: http://domain.com/controller/value

and in controller i have this situation
Code:
<?php

class Example extends Controller {
    function Example()
    {
        parent::Controller();
    }
    
    function index($value)
    {
        // value is the value insert in the url... this vork for other function (if i specify the funcition in the url) but not for the default index()
        do something
    }

    
}


can you help me?
#2

[eluser]Pedro Luz[/eluser]
Code:
class Base extends CI_Controller {

    function __construct()
    {
        parent::__construct();
    }
    
    function index($value)
    {
        echo $value;
    }
}

http://domain.com/base/5
#3

[eluser]guidorossi[/eluser]
It should be:

Code:
<?php

class Example extends Controller {
    function Example()
    {
        parent::Controller();
    }
    
    function index()
    {
        $value = $this->uri->segment(2);
    }

    
}

and in config route.php

Code:
$route['example/:any'] = "example/index";
#4

[eluser]InsiteFX[/eluser]
It depends on if he is running CI 1.7.X or CI 2.0.0

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB