By default Joomla 3 system messages (messages, notices, warnings) are displayed in a certain position of the template using

<jdoc:include type="message" />

Would it be possible getting more control over those messages and display them in different positions inside my own component's container?

I've tried using the jdoc above inside my component's views (cheap shot) but no luck. Is there any way I can "capture" messages generated by my component using Joomla's standard system messaging system and display them wherever I want?

Thanks in advance.

2 Answers 2


Ok, looks like digging a bit more I found an answer to my own question. Basically I found this plugin:


It's not exactly what I need, but checking its code I figured out the way to go, which could be summarized as follows (in case someone gets here looking for the same question):

  1. If you want to do it the right way, you need to take care of default's Joomla messages displayed in the template via <jdoc:include type="message" />, so that messages are not displayed twice
  2. The only way to handle that is using a plugin that will be triggered on the onBeforeRender event
  3. In that event you need to:
    • Retrieve the messages using $app = JFactory::getApplication(); $messageQueue = $app->getMessageQueue();
    • Process the messages as needed to output them in your component
    • Clear the messages queue, so messages are not displayed twice. In previous Joomla versions, it was possible to directly clear the queue with a method, but in Joomla 3 you need to replace the existing queue with an empty one
  4. That's it, you have messages enqueued in default's Joomla messaging system available in your component.

This needs some work, but I think the overall path to follow is clear. Hope it's useful for someone else in a similar situation.


To complete this (good) answer from Isidro, notice that as of today (Joomla 3.8.12), the getMessageQueue() function can be called with "true" (getMessageQueue(true)) as the parameter to purge/clear the message queue.

Finally, to get the messages stored in the expected manner for the layout to display them, call this piece of code (extracted from MessageRenderer::getData()):

// Initialise variables.
$lists = array();
// Get the message queue
$messages = \JFactory::getApplication()->getMessageQueue();
// Build the sorted message list
if (is_array($messages) && !empty($messages))
    foreach ($messages as $msg)
        if (isset($msg['type']) && isset($msg['message']))
            $lists[$msg['type']][] = $msg['message'];

Then you get $lists sorted in the correct manner.

  • just an fyi, you can streamline your snippet with these minor tweaks: 3v4l.org/DZGWd Commented Jun 10, 2019 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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