• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable To call function from URL

#1
[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

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

#3
[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.

#4
[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

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

Thanks in advance

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.