/ Published in: PHP
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.
With CSS styles for notification boxes this is good to quick and nice looking show alerts and other infos. See demo for more examples.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * Show notification boxes * * @param type $aMessages * @return string */ function showMessage($aMessages) { /* $aMessages['lightbulb'][] = "Sample lightbulb message"; // Default type of message $aMessages['success'][] = "Sample success message"; $aMessages['messages'][] = "Sample messages message"; $aMessages['information'][] = "Sample information message"; $aMessages['warning'][] = "Sample warning message"; $aMessages['failure'][] = "Sample failure message"; */ $out = ''; foreach($aMessages as $type=>$messages) { foreach($messages as $info) { switch($type) { case 'warning': $class = 'warning'; $title = 'Warning!'; break; case 'success': $class = 'success'; $title = 'Success!'; break; case 'failure': $class = 'failure'; $title = 'Failure!'; break; case 'information': $class = 'information'; $title = 'Information!'; break; case 'messages': $class = 'messages'; $title = 'Message!'; break; default: $class = 'lightbulb'; $title = 'Tip!'; break; } $out .= '<div class="notification '.$class.'"><p><strong>'.$title.'</strong>'.$info.'</p></div>'; } } return $out; } } ?>
URL: http://melma.pl/dema/demo-notification-boxes