Difference between revisions of "Display error messages and notices"

From Joomla! Documentation

(New page: Errors, warnings and notices can be displayed from any component, module, plugin or template using the method outlined below (took me some time to figure this out, might help someone else)...)
 
Line 7: Line 7:
  
 
The second argument to the enqueueMessage()-function is the type of message. Default is 'message', but both error, and I believe also 'warning' will work. The api for the JApplication-object can be found at:  
 
The second argument to the enqueueMessage()-function is the type of message. Default is 'message', but both error, and I believe also 'warning' will work. The api for the JApplication-object can be found at:  
[[http://api.joomla.org/Joomla-Framework/Application/JApplication.html]]
+
[[http://api.joomla.org/Joomla-Framework/Application/JApplication.html JApplication API]]
 
The error message will now be displayed if the message-tag is present in your template. The message-field is added with the following statement in your template:  
 
The error message will now be displayed if the message-tag is present in your template. The message-field is added with the following statement in your template:  
  
 
<jdoc:include type="message" />
 
<jdoc:include type="message" />

Revision as of 14:49, 24 October 2009

Errors, warnings and notices can be displayed from any component, module, plugin or template using the method outlined below (took me some time to figure this out, might help someone else):

//Get a handle to the Joomla!-application object $app =& JFactory::getApplication(); //add a message to the message queue $app->enqueueMessage(JText::_('Random error occured'), 'error');

The second argument to the enqueueMessage()-function is the type of message. Default is 'message', but both error, and I believe also 'warning' will work. The api for the JApplication-object can be found at: [JApplication API] The error message will now be displayed if the message-tag is present in your template. The message-field is added with the following statement in your template:

<jdoc:include type="message" />