CodeIgniter Forums
Unable To call function from URL - 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: Unable To call function from URL (/showthread.php?tid=13965)



Unable To call function from URL - El Forum - 12-13-2008

[eluser]Blue Sapphire[/eluser]
Hi!
I have following class code :

Code:
<?php

class Main extends Controller {

    function Main()
    {
        parent::Controller();
    }
/****************************************************/    
    function index()
    {
        echo 'index Function';
        //$this->load->view('admin/adwc');
    }
/***************************************************/    
    function myFunc()
    {
        echo 'Another Function';
    }
/**************************************************/    
    
}

?>


I have set route in routes.php as follows:
Code:
$route['admin'] = "admin/main";

I am using following url:

1- http://localhost/personal/com/admin/ [This works fine and shows message]

2- http://localhost/personal/com/admin/myFunc [This url gives me '404 Page Not Found' error].

Can some one guide me where I am wrong and in solving this problem.

Thanks in advance


Unable To call function from URL - El Forum - 12-13-2008

[eluser]Blue Sapphire[/eluser]
Any solution?


Unable To call function from URL - El Forum - 12-14-2008

[eluser]KPowell[/eluser]
When you set your routes, the first parameter is the controller, the second the method. So, in your example, you're trying to call the "main" method of the "admin" controller, which doesn't add up to what you have. If your application is admin, then setting the route to just "main" should do what you need.


Unable To call function from URL - El Forum - 12-14-2008

[eluser]Blue Sapphire[/eluser]
Thanks for guidance. I have following scenario:

1- 'admin' is sub directory of 'controllers' directory. 'admin' directory will hold all admin related controllers.

2- 'main' is default controller in 'admin' sub directory. There will be many more controllers in 'admin' sub directory.

3- 'myFunc' is function in 'main' controller.

Your guidance will be higly appreciated in this scenario.

Thanks in advance


Unable To call function from URL - El Forum - 12-15-2008

[eluser]Blue Sapphire[/eluser]
Any solution ?

Thanks in advance


Unable To call function from URL - El Forum - 12-15-2008

[eluser]yusufdestina[/eluser]
try http://localhost/personal/com/admin/main/myFunc