So I like the Twitter Bootstrap alerts and I wanted a way to use them in my CakePHP projects when controller actions return flash messages.

Element

app/View/Elements/alert-box.ctp

<div class="alert <?php echo $class;?>">
    <?php echo $message; ?>
    <a href="#" class="close" onclick="$(this).parent().fadeOut();return false;">&times;</a>
</div>

Usage

The element is used from the controller by appending the element and class to the $this->element() call.
Success

<?php $this->Session->setFlash(__('The article has been saved'), 'alert-box', array('class'=>'alert-success')); ?>

Failed

<?php $this->Session->setFlash(__('The article could not be saved. Please, try again.'), 'alert-box', array('class'=>'alert-error')); ?>