O'Reilly logo

CouchDB and PHP Web Development Beginner's Guide by Tim Juravich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — showing alerts

In this section, we'll use our existing variables in bones to allow us to show alert messages to our users.

  1. Open lib/bones.php and create a new function called display_alert(). This function will be called to see if the alert variable is set. If the alert variable is set, we will echo some HTML to show the alert box on the layout.
    public function display_alert($variable = 'error') {
    if (isset($this->vars[$variable])) {
    return "<div class='alert alert-" . $variable . "'><a class='close' data-dismiss='alert'>x</a>" . $this- >vars[$variable] . "</div>";
    }
    }
    
  2. Add code to layout.php, right inside of the container div to display the Flash call the display_flash function.
    <div class="container">
    <?php echo $this->display_alert('error'); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required