How to override Joomla System Messages - message.php template

Kristian Hildebrandt picture Kristian Hildebrandt · May 9, 2012 · Viewed 9.4k times · Source

Joomla by default renders its system messages (errors, notices etc.) in

libraries/joomla/document/html/renderer/message.php.

For my own template, I would like to customize the way these messages are displayed. However it does not seem to be possible in the traditional way, using template overrides.

Is anyone here aware of a way to accomplish something like this?

Answer

Fedik picture Fedik · Dec 24, 2012

For Joomla! 1.7 - 2.5

You need copy libraries/joomla/document/html/renderer/message.php in to templates/YOUR_TEMPLATE/html/message.php

Then in index.php of YOUR_TEMPLATE you need to include the file (as it is not automatically included like other overrides):

// Message overwrite
require_once JPATH_ROOT .'/templates/'. $this->template .'/html/message.php';

Now you can safety overwrite the JDocumentRendererMessage::render() function there ;)

For Joomla! 3.x

You just need make html/message.php file in YOUR_TEMPLATE. This file should contain function renderMessage(). Check the isis default template, as example.