Skip to main content
deleted 14 characters in body
Source Link
latvian
  • 807
  • 12
  • 25

We like to share the status messages in multiple location in single request, so we retrieve them:

function get_messages(){
    status_message_tapi$status_messages = array();
    //loop through each message type
        foreach (drupal_get_messages(null, false) as $type => $messages) {
               foreach($messages as $key => $message){
                   $status_message_tapi[$type]['enabled']$status_messages[$type]['enabled'] = true;
                   $status_message_tapi[$type]['messages']$status_messages[$type]['messages'] = array(
                       'message' => $message
                   );
               }
        }
return status_message_tapi;$status_messages;
}

Here, since we are passing "FALSE" to the drupal_get_messages function the messages are not reset which is what we like because multiple locations gets to call this function, however. At some point, the messages need to be reset.

  1. One option is to clear messages at the last point of the request. Where and how to do that?

  2. Another option, would implement a cache and run drupal_get_messages() with "TRUE" to call once and reset at the same time. I am not familiar with cache in Drupal or PHP. How to do that?

In short, we like to access status messages in multiple locations and $variable['messages'] is not available to serve the purpose. How to do that? Thank You for help

We like to share the status messages in multiple location in single request, so we retrieve them:

function get_messages(){
    status_message_tapi = array();
    //loop through each message type
        foreach (drupal_get_messages(null, false) as $type => $messages) {
               foreach($messages as $key => $message){
                   $status_message_tapi[$type]['enabled'] = true;
                   $status_message_tapi[$type]['messages'] = array(
                       'message' => $message
                   );
               }
        }
return status_message_tapi;
}

Here, since we are passing "FALSE" to the drupal_get_messages function the messages are not reset which is what we like because multiple locations gets to call this function, however. At some point, the messages need to be reset.

  1. One option is to clear messages at the last point of the request. Where and how to do that?

  2. Another option, would implement a cache and run drupal_get_messages() with "TRUE" to call once and reset at the same time. I am not familiar with cache in Drupal or PHP. How to do that?

In short, we like to access status messages in multiple locations and $variable['messages'] is not available to serve the purpose. How to do that? Thank You for help

We like to share the status messages in multiple location in single request, so we retrieve them:

function get_messages(){
    $status_messages = array();
    //loop through each message type
        foreach (drupal_get_messages(null, false) as $type => $messages) {
               foreach($messages as $key => $message){
                   $status_messages[$type]['enabled'] = true;
                   $status_messages[$type]['messages'] = array(
                       'message' => $message
                   );
               }
        }
return $status_messages;
}

Here, since we are passing "FALSE" to the drupal_get_messages function the messages are not reset which is what we like because multiple locations gets to call this function, however. At some point, the messages need to be reset.

  1. One option is to clear messages at the last point of the request. Where and how to do that?

  2. Another option, would implement a cache and run drupal_get_messages() with "TRUE" to call once and reset at the same time. I am not familiar with cache in Drupal or PHP. How to do that?

In short, we like to access status messages in multiple locations and $variable['messages'] is not available to serve the purpose. How to do that? Thank You for help

Source Link
latvian
  • 807
  • 12
  • 25

What is Best Way to Retrieve Status Messages in Multiple Locations?

We like to share the status messages in multiple location in single request, so we retrieve them:

function get_messages(){
    status_message_tapi = array();
    //loop through each message type
        foreach (drupal_get_messages(null, false) as $type => $messages) {
               foreach($messages as $key => $message){
                   $status_message_tapi[$type]['enabled'] = true;
                   $status_message_tapi[$type]['messages'] = array(
                       'message' => $message
                   );
               }
        }
return status_message_tapi;
}

Here, since we are passing "FALSE" to the drupal_get_messages function the messages are not reset which is what we like because multiple locations gets to call this function, however. At some point, the messages need to be reset.

  1. One option is to clear messages at the last point of the request. Where and how to do that?

  2. Another option, would implement a cache and run drupal_get_messages() with "TRUE" to call once and reset at the same time. I am not familiar with cache in Drupal or PHP. How to do that?

In short, we like to access status messages in multiple locations and $variable['messages'] is not available to serve the purpose. How to do that? Thank You for help