Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Create base controller from template controller?
  • Hi Guys! I'm trying to create admin base controller by extending the Controller_Template ( Controller_Template) here's my code for the base controller:
    class Controller_Admin extends \Controller_Template{
    
    }
    

    Now, within modules when i try to create a controller extedending the the admin controller I get this error:
    
     3Class Controller_Messaging extends \Controller_Admin 
     4{ 
     5    public function action_index() 
     6    {
     7        $data = array();
     8    $this->template->title = 'Example Page';
     9    $this->template->content = \View::factory('inbox', $data);
    10  
    11}
    12
    13public function action_compose(){
    
    Backtrace
    
       1. COREPATH/base.php @ line 201
       2. APPPATH/modules/messaging/classes/controller/messaging.php @ line 8
       3. COREPATH/classes/request.php @ line 328
       4. DOCROOT/index.php @ line 42
    
    

    ErrorException [ Warning ]: Attempt to assign property of non-object What am I doing wrong? Thanks.
  • Do you have a before() method in there? And if so does it call parent::before()? Otherwise the template property isn't instantiated.
  • And if not, by default it attempts to load a view called 'template'. Does that exist?
  • Hi guys! Yes it does have before() method in there but not sure if itself calls parent method.(not front of the pc). Is it wrong to have the before() method in there? The docs talks using this method to verify if the user is authenticated etc.
  • Do you have a before() method in there? And if so does it call parent::before()? Otherwise the template property isn't instantiated.
    Try to guess what I tried to suggest you change about your before() method in my quote above... :P

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion