call other module controller

edited October 2013 in Modules
I made a module 'mymenu' that has a controller 'mymenu'. 'mymenu' has a public method single_level()

single level return 'html' content.

I made a mymenu object and call single_level()

but it is showing error.

-----------------------------
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Mymenu::$fuel_auth

Filename: libraries/Fuel_base_controller.php

Line Number: 31

Fatal error: Call to a member function user_data() on a non-object in D:\xampp\htdocs\ufcm\fuel\modules\fuel\libraries\Fuel_base_controller.php on line 31
----------------------------------------
--------------mymenu.php------------------------
<?php
require_once(MODULES_PATH.'/fuel/libraries/fuel_base_controller.php');

class Mymenu extends fuel_base_controller{

function __construct() {
parent::__construct();
}

public function single_level(){
$fuel_auth=new Fuel_auth();

$user=$fuel_auth->valid_user();

$this->load->model('menu_model');
$menu['items']= $this->menu_model->getItems($user['id']);
return $this->load->view('single_level',$menu,TRUE);
}
}

--------------------ufcm.php-------------------------
<?php
require_once(MODULES_PATH.'/ufcm/libraries/ufcm_base_controller.php');
require_once(MODULES_PATH.'/mymenu/controllers/mymenu.php');

class ufcm extends Ufcm_base_controller {

function __construct()
{
parent::__construct();
$this->__check_permission();
}

function user(){
$template=new Template();

$mymenu=new Mymenu();

echo $mymenu->single_level();


$template->Template('user');
$template->render(FALSE);
}
}

Please solve this issue like previous problem.

Comments

  • edited 4:40AM
    What version of FUEL are you using (0.93 or 1.0)? Also, it appears that you are loading one controller into another. Is there a reason for doing that as opposed to creating Mymenu library or helper function?
  • FUEL CMS version 0.9.3
  • HI admin What is the problem and what is the solution
  • edited 4:40AM
    Try loading the session library in the constructor of your library that uses Fuel_auth.
    $this->load->library('session');
  • edited October 2013
    Download and setup my project.
    go to http://localhost/ufcm/profile using browser and experience the problem


    Download link: https://atishdipankaruniversity.sharefile.com/?cmd=rp&id=27fecad4882a45a3

    username: aslampatwarybd@gmail.com
    password: XXXX

    Download the project ufcm.zip

    PLease solve the issue
  • edited 4:40AM
    That login is asking for a security question.
  • edited 4:40AM
    I've removed your password and security question answers for security reasons. It looks like you aren't requiring the Fuel_auth file first. Try the following:
    public function single_level(){ require_once(FUEL_PATH.'libraries/Fuel_auth.php'); $user=new Fuel_auth(); $user_id=$user->user_data('id'); $this->load->model('menu_model'); $menu['items']= $this->menu_model->getItems($user_id); echo $this->load->view('single_level',$menu,TRUE); }
  • http://localhost/ufcm/profile
    use this link in your local server
    and see the error
  • edited 4:40AM
    Curious as to why you are including a controller file into another controller file. Wrapping the mymenu_base_controller.php require_once statement should fix the issue:
    if (!class_exists('Fuel_base_controller')) { require_once(MODULES_PATH.'/fuel/libraries/fuel_base_controller.php'); }
  • hi what is the solution?
  • edited 4:40AM
    Does the above fix it?
  • no
Sign In or Register to comment.