How to Display Messages and Notices in Joomla

Errors, warnings and notices can be displayed from any component, module, plugin or template. The messages use the standard bootstrap CSS styles for alerts.

// Get a handle to the Joomla! application object
$application = JFactory::getApplication();

// Add a message to the message queue
$application->enqueueMessage(JText::_('SOME_ERROR_OCCURRED'), 'error');

The second argument to the enqueueMessage function is the type of the message. The default is 'message', but 'error' results in a different style for the message.

Where it is displayed?

The message is displayed in place of a special jdoc:include statement in the template. Place the following in your template at the location where you want messages to appear:

<jdoc:include type="message" />

 

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive