Return to Snippet

Revision: 65224
at November 11, 2013 04:51 by melma


Updated Code
<?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 = '';
	
	if(isset($aMessages) && count($aMessages)>0) {
		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;
	}
}
?>

Revision: 65223
at November 11, 2013 02:53 by melma


Updated Code
<?php
/**
 * Show stylized messages
 * 
 * @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 = '';
	
	if(isset($aMessages) && count($aMessages)>0) {
		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;
	}
}
?>

Revision: 65222
at November 10, 2013 09:57 by melma


Initial Code
<?php
/**
 * Show stylized messages
 * 
 * @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";
	$aMessages['success'][] = "Sample success message";
	*/
	$out = '';
	
	if(isset($aMessages) && count($aMessages)>0) {
		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;
	}
}
?>

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

Initial Description
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.

Initial Title
PHP nice looking notification boxes

Initial Tags

                                

Initial Language
PHP