1

In my component I am assigning the data from the model to the view using

class FileUploaderViewFileUploader extends JViewLegacy  
{  
    // Overwriting JView display method  
    function display($tpl = null)   
    {  
        // Assign data to the view  
        $this->items = $this->get('Items'); // => This causes the error    
        // Display the view  
        parent::display($tpl);  
    }  
}  

The error at my website I get is:

Error: 0  
Using $this when not in object context

Anybody an idea what happened here? This code worked well under PHP 5.6.x as well as PHP 7.0.26.
Thank you in advance.

Best regards
Andreas

  • 1
    For Joomla on php7+ you have to turn on debug to see the line numbers of the fatal error in the stacktrace. I don't think the line you point to is throwing the error. – jamesgarrett Jan 4 '18 at 22:53
  • I should also add for clarity that for Joomla on php7+ you can only write fatal errors to the error log when you have debug on (though usually I find the stack trace number is fine). By 'debug' I mean set 'Yes' in Administration > Global Configuration > System > Debug System. – jamesgarrett Jan 4 '18 at 23:09
0

Are you sure the error is coming from that line? If so, you may want to review your model's getItems method (include it also in your question for review). Likely you might be calling a static method somewhere, where you can't use $this.

Also, what is your Joomla version - is it up-to-date? Have you just updated Joomla? Are you sure the update went smoothly? Note that this error might be coming from anywhere... e.g. a plugin, or core code if an update didn't completed successfully.

Enable error reporting and debug and see what else information you get from there.

  • Thank you for all your answers. So the Joomla version is up to date at 3.8.3. I enabled the error reporting and the debug mode, but the system fails and do not show the console at that time. :-( – Andreas Isele Jan 13 '18 at 15:18
  • Found the issue. I called JSite in my model. I changed it to: $app = JFactory::getApplication(); $menu = $app->getMenu(); which fixed the issue. Thank you all. – Andreas Isele Jan 14 '18 at 9:53
  • @AndreasIsele please post your solution as an answer and award your answer the green tick so that this page is deemed resolved by the system. Thank you for your effort. – mickmackusa Dec 2 '18 at 11:31
-1

Found the issue. I called JSite in my model.

I changed it to:

$app = JFactory::getApplication(); 
$menu = $app->getMenu();

This fixed the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.