Welcome Guest, Not a member yet? Register   Sign In
Loading controllers from within controller

How do i load a controller from within a controller.

For example,

I am using tank_auth library which has a controller called auth which calls a view called login_form to display the login form page.

Now I want to display this login form in the top of the homepage.

the home page is displayed by another controller called home_controller

how do i call the auth controller from the home-controller.

Please help


from home_controller to call method in it with him ?
class  home_controller  extends ci_controller {

  function methodOne()
echo "....";

function methodTwo()
echo "aaa";

function index()
echo " bbbb";


If i udenterstand you corectly

thanks for replying..

but what if my method one is already present in say b_controller .. do i have to write the method one again in home-controller.

isn't there a way i can call method one in b_controller from home_controller ?


I believe he's wanting to call a different controller's method from the current controller. I think that's what HMVC allows?

<waits patiently for someone more experienced in that area to respond....*cough* cronix, insite..>

yes precisely what i wanted. a search on HMVC lead me to some articles - but i dont think - i need to go all the way to create spearate M-V-C for each module.

What i am asking for is an everyday phenomena on websites - including the way its displayed here at the top of this forum.

All i want is to display the login form at the top of each page and if the user is logged the form is replaced by some welcome message - like "Hello Username".

thanks a lot - i am new to ci - read through most of the tutorials - but nothing that came close to answering this issue.

why not just define the is_logged_in method from the auth library and echo the difference if that makes sense

Create a base controller in the application/core/ directory:

class MY_Controller extends CI_Controller{

    function _head(){

_head() will be available in all descendants of MY_Controller

class Blog extends MY_Controller{

    function hello(){

Theme © iAndrew 2016 - Forum software by © MyBB