Compago knowledge

  • Increase font size
  • Default font size
  • Decrease font size
Home Manuali Programmazione How to create and delete message in Joomla

How to create and delete message in Joomla

E-mail Stampa PDF

In Joomla it's be very usefull to show some message for the user using the application framework, to do this is enought to have the access to the application object:

JFactory::getApplication()->enqueueMessage('text to show','message');

where the secon parameter could be "message" or "notice" or "error". 
Untill now is quite easy but the application don't let the programmers delete the message already enqueued. Here is how to create and delete message in Joomla, using the message queue:

function addMsg() { 
 //optional check if the queue is empty 
 if (count($q)==0){ 
   //add message
function delMsg() { 
 $appReflection = new ReflectionClass(get_class($app)); 
 $_messageQueue = $appReflection->getProperty('_messageQueue'); 
 $messages = $_messageQueue->getValue($app); 
 foreach($messages as $key=>$message) { 
   if($message['message'] == 'ACmsg') {
     //delete message

The reflection class is used to get information and modify the messageQueue of the application.