PHP nice looking notification boxes


/ Published in: PHP
Save to your folder(s)

Simple function to quick implements mesage boxes on your site (good for develop versions, or website control panel). Available types of notifications: lightbulb, success, message, information, warning, failure.
With CSS styles for notification boxes this is good to quick and nice looking show alerts and other infos. See demo for more examples.


Copy this code and paste it in your HTML
  1. <?php
  2. /**
  3.  * Show notification boxes
  4.  *
  5.  * @param type $aMessages
  6.  * @return string
  7.  */
  8. function showMessage($aMessages) {
  9. /*
  10. $aMessages['lightbulb'][] = "Sample lightbulb message"; // Default type of message
  11. $aMessages['success'][] = "Sample success message";
  12. $aMessages['messages'][] = "Sample messages message";
  13. $aMessages['information'][] = "Sample information message";
  14. $aMessages['warning'][] = "Sample warning message";
  15. $aMessages['failure'][] = "Sample failure message";
  16. */
  17. $out = '';
  18.  
  19. if(isset($aMessages) && count($aMessages)>0) {
  20. foreach($aMessages as $type=>$messages) {
  21. foreach($messages as $info) {
  22. switch($type) {
  23. case 'warning': $class = 'warning'; $title = 'Warning!'; break;
  24. case 'success': $class = 'success'; $title = 'Success!'; break;
  25. case 'failure': $class = 'failure'; $title = 'Failure!'; break;
  26. case 'information': $class = 'information'; $title = 'Information!'; break;
  27. case 'messages': $class = 'messages'; $title = 'Message!'; break;
  28. default: $class = 'lightbulb'; $title = 'Tip!'; break;
  29. }
  30. $out .= '<div class="notification '.$class.'"><p><strong>'.$title.'</strong>'.$info.'</p></div>';
  31. }
  32. }
  33. return $out;
  34. }
  35. }
  36. ?>

URL: http://melma.pl/dema/demo-notification-boxes

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.