Welcome Guest, Not a member yet? Register   Sign In
Controller Problem
#1

[eluser]BD-CI-Programmer[/eluser]
Dear All,
I am two controller like this

Code:
<?php
class Bangladesh extends Controller
{
    function Bangladesh ()
    {
        parent::Controller();
    }
function hello_bangladesh()
     {
// Code

     }

}
?>

And other

Code:
<?php
class World extends Controller
{
    function World()
    {
        parent::Controller();
    }
function hello_world()
     {
// Code

     }

}
?>


Now I want to call function hello_world in the hello_bangladesh function.

How it Possible...
#2

[eluser]xwero[/eluser]
It depends on what the method does. If the method does general things it's best you add the hello_world method to a library. If the method is a partial you can use one of the module libraries.
#3

[eluser]BD-CI-Programmer[/eluser]
[quote author="xwero" date="1208777403"]It depends on what the method does. If the method does general things it's best you add the hello_world method to a library. If the method is a partial you can use one of the module libraries.[/quote]

Thanks xwero. I know if you add this function on libraries then it is very easy solution. but i want to call it another controller.
#4

[eluser]xwero[/eluser]
If you search the forum others responded with solutions similar to mine. If you have to reuse a method you have to rethink the place of the method. The two most common answers are

- add it to a library
- use a base controller and extend the controllers that need the method.




Theme © iAndrew 2016 - Forum software by © MyBB