How to override Joomla System Messages - message.php template
Asked Answered
R

4

6

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?

Ruination answered 9/5, 2012 at 20:2 Comment(0)
A
20

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.

Alienage answered 24/12, 2012 at 11:26 Comment(2)
This works really well without hacking the core and purely overrides the default.Maurya
At J3.x: place "message.php" at "{my_template}/html/layouts/joomla/system" and extract the messages from $displayData['msgList'] (check Beez3 Template)Dur
N
0

Templates overrides only work with the MVC - i.e. views and module chrome.

Without hacking the core all you can do is control what HTML tags are wrapped around the <jdoc:include type="message" /> tag in the template and the CSS defined for the elements of the message block.

Nonstandard answered 9/5, 2012 at 22:10 Comment(0)
P
0

A more elegant way to include your override in the template directory is to include the file in a system plugin:

public function onAfterInitialise() {
    $app = JFactory::getApplication();
    if ($app->isSite()) {
        $template = $app->getTemplate();
        if (!class_exists('JDocumentRendererMessage') && file_exists(JPATH_THEMES . '/' . $template . '/html/message.php')) {
            require_once JPATH_THEMES . '/' . $template . '/html/message.php';
        }
    }
    return true;
}
Passable answered 2/3, 2014 at 12:15 Comment(1)
No it's not. If one just means to override the template, just place the appropriate files where they're supposed to be... no need to code plugins to do what is already part of the MVC.Dur
S
0

http://extensions.joomla.org/extensions/style-a-design/popups-a-iframes/26551

OR

http://extensions.panchsoft.com/product/1-popup-system-messages.html

Use this extension for default messages for Joomla.

Sorption answered 2/8, 2014 at 4:51 Comment(1)
try to explain answer instead of giving links...b'coz these links may be unavailable in futureHaploid

© 2022 - 2024 — McMap. All rights reserved.