My fix to`0 - Using $this not in object context` in Joomla!
JoomlaAfter migrating, the Joomla! page would not show up.
Instead, only the error "0 - Using $this not in object context" was showing up.
In my case, I was able to fix the issue by replacing – in the code of the template – all JFactory::getMenu()
with $application->getMenu()
, where $application
came from $application = JFactory::getApplication()
.
Note that this may not be the only possible fix for this error.
It highly depends on the code you have.
Generally, the errormessage indicates the underlying problem: somewhere in Joomla!s code, there is a $this
inside a class which – in your code – is used, without the class being instantiated properly.
In the case mentioned above, the class is initialized statically.
This, because that was valid apparently in elder Joomla! versions.
To find the source of your problem, I recommend to enable Joomla! debugging as well as PHP logging in order to get the full stack trace and find the origin of the wrongly instantiated class.