How can I load a page with a system message?

Specifically I have a link and I would like that when a user clicks on the link it opens a specific page with a system message I pass it.

I can see system messages just fine on my site, my template has

<jdoc:include type="message" />

I just don't know what the right code would be to do this. Perhaps the link should actually be a button with an onclick event?


You can inject system messages at any point in the page render cycle like so:

JFactory::getApplication()->enqueueMessage('My glorious message','error');

The jdoc tag basically creates the place host and loads needed files required to inject and display messages. Hope this helps, but depending on exactly where you plan on creating message in code could be relevant. If you are having issues still post the code where you are creating the message.

* Edit 1 *

We can leverage your custom template and Joomla's Output Override's feature to accomplish what you would like. For this example, I'm assuming we will overriding the article component view.

First thing is to create the directory path in your custom template's root folder:


Next would be to copy the core content component default.php file to the new directory, you would find the file for this example at this path:


Now, at the top of this file, you would add the method to queue up a new system message:

JFactory::getApplication()->enqueueMessage('My glorious message','error');

I pasted three links to Joomla Docs regarding overrides to provide more detailed explanations.

  • Thanks Brian! Yes I had got as far as figuring out how to make a system message appear on the page I am currently on. But I still don't know how to make that message appear on the a page I want to load. The creation of the message is very simple, its just the same string that loads every time. – Hannah Smith Apr 21 '15 at 0:03
  • So my link looks like this ` <div class="btn btn-primary button lsbButton"> <a href="index.php/animals" title="Add multiple animals to mob"><i class="icon-plus "></i>Add multiple animals</a> </div> ` and I have really no idea how I incorporate the code you suggested above into it! :0( – Hannah Smith Apr 21 '15 at 0:08
  • The destination page, is that core Joomla or a custom component you wrote? – Brian Bolli Apr 21 '15 at 0:21
  • It is a Joomla component page - so I think you would count that as core Joomla? Certainly not a custom component I wrote, it is a page from the Fabrik component – Hannah Smith Apr 21 '15 at 0:58
  • Do you have a custom template you are working with, we could leverage template overrides if so – Brian Bolli Apr 21 '15 at 15:04

Using Brian's answer (thanks very much @Brian Bolli) and this post - https://stackoverflow.com/questions/19323010/execute-php-function-with-onclick - I figured out how to make the link load a page with the message at the top.

The link's code looks like this:

<a href="index.php/animals?multiple=true" title="Add multiple animals to mob"><i class="icon-plus "></i>Add multiple animals</a>

It is passing a variable to the page I want to load in the url called multiple and it is set to true.

In the page template that loads, the code looks like this:

if (isset($_GET['multiple'])) :
    $msg = 'Very helpful message';
    JFactory::getApplication()->enqueueMessage($msg, 'message'); 

It is checking to see if the variable has been set and then if so, it will display the message I want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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