Skip to content

Instantly share code, notes, and snippets.

@ccagle8
Last active December 19, 2015 14:48

Revisions

  1. ccagle8 revised this gist Jul 11, 2013. 1 changed file with 5 additions and 7 deletions.
    12 changes: 5 additions & 7 deletions display-alert-msg-bootstrap.php
    Original file line number Diff line number Diff line change
    @@ -41,14 +41,12 @@ function display_messages() {
    <!doctype html>
    <html lang="en">
    <head>
    <title>Twitter Bootstrap Messages</title>
    <title>Twitter Bootstrap Messages</title>

    <!-- Dont forget to download and use your own copy -->
    <link href="http://twitter.github.io/bootstrap/assets/css/bootstrap.css" rel="stylesheet">
    </head>
    <body>

    <?php display_messages(); ?>

    </body>
    </head>
    <body>
    <?php display_messages(); ?>
    </body>
    </html>
  2. ccagle8 created this gist Jul 11, 2013.
    54 changes: 54 additions & 0 deletions display-alert-msg-bootstrap.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    <?php
    /**
    * Display Alert Messages
    *
    * Looks for a global variable, and displays any test that variable has
    *
    * @uses GLOBALS $notice, $error, $success, $infonotice, $alertBlock
    * @return string
    */
    function display_messages() {
    global $success;
    global $error;
    global $notice;
    global $infonotice;
    global $alertBlock;
    if ($alertBlock) $alertBlock = ' alert-block ';

    if ($notice) {
    echo '<div class="alert '.$alertBlock.'"><button type="button" class="close" data-dismiss="alert">&times;</button>'. $notice .'</div>';
    }
    if ($error) {
    echo '<div class="alert alert-error '.$alertBlock.'"><button type="button" class="close" data-dismiss="alert">&times;</button>'. $error .'</div>';
    }
    if ($success) {
    echo '<div class="alert alert-success '.$alertBlock.'"><button type="button" class="close" data-dismiss="alert">&times;</button>'. $success .'</div>';
    }
    if ($infonotice) {
    echo '<div class="alert alert-info '.$alertBlock.'"><button type="button" class="close" data-dismiss="alert">&times;</button>'. $infonotice .'</div>';
    }
    }


    # test the messages
    $error = 'Your payment has failed.';
    $success = 'Your payment has succeeded!';
    $notice = '<b>Tip:</b> When walking, you should have your eyes opened.';
    $alertBlock = true;
    $infonotice = '<h4>Welcome!</h4><p>Thanks for signing up. Check out this <a href="">great tutorial</a> to get you started.</p>';

    ?>
    <!doctype html>
    <html lang="en">
    <head>
    <title>Twitter Bootstrap Messages</title>

    <!-- Dont forget to download and use your own copy -->
    <link href="http://twitter.github.io/bootstrap/assets/css/bootstrap.css" rel="stylesheet">
    </head>
    <body>

    <?php display_messages(); ?>

    </body>
    </html>