Custom module bug: Don't use any variable named $content.

The support for Joomla 2.5 ended on December 31, 2014. Possible bugs in Joomla 2.5 will not be patched anymore. This forum has been closed. Please update your website to Joomla 3.x

Moderator: ooffick

Forum rules
Please use the official Bug Tracker to report a bug:
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Fri Jun 17, 2011 1:49 am

Custom module bug: Don't use any variable named $content.

Post by MonkeyT » Tue May 28, 2013 5:05 pm

There is a variable scope error that is built into Joomla's custom module mechanism.
It really is a silly mistake, and could probably be fixed in a heartbeat by anyone familiar with the Joomla CMS core.

Inside a custom module, if you use a variable with the name "content", Joomla will dump that variable's value to the screen once the module is rendered.

Proof? Add this line to the main file of your module:

$content = "Malarkey";

When the module renders to the screen, Joomla will add the word "Malarkey" to the end of the text. I do not know where this rendering occurs within Joomla's core code, but if you avoid that variable name, you'll never see it happen.

I hope this helps.


Return to “Joomla! 2.5 Bug Reporting”