Note - adampatterson/Dingo-Framework GitHub Wiki

###Overview The note library allows you to easily create cross-page notifications. To load the note library manually you may do this:

load::library('note');

###Configuration Notes are stored as cookies. You may change the cookie settings for notes by changing the following code found in the config.php main configuration file:

/* Notes */
config::set('notes',array('path'=>'/','expire'=>'+5 minutes'));

Because notes are deleted after they are accessed, they are not ideal for storing application data; such as authentication information. Also, this means that notes only have to last for as long as they need to be accessed once. This allows notes to have a short expiration setting.

###Set Creates a note and stores it to a cookie:

note::set("regular","one","Hello, World!");

This will create a note with the type regular, has the name one, that contains the message Hello, World!. Type may be any of the following values:

  • regular
  • success
  • warning
  • error

Alternatively, instead of using note->set() to create notes, you may use any of the following methods to create notes with a specific type:

note::regular("one","Hello, World!");
note::success("two","I'm a success message!");
note::warning("three","I'm a warning message!");
note::error("four","I'm a error message!");

NOTE: Because the note library uses cookies to store data, notes are limited in length based on how much data the browser will allow you to store in a cookie.

###Get Returns the value and type of a note as an array. Returns FALSE if note cannot be found. The note is automatically deleted after it is accessed. The note->get() method may be used in a view like so:

<?php if($note = note::get('one')): ?>

	<p class="<?php echo $note['type']; ?>"><?php echo $note['content']; ?></p>

<?php else: ?>

	<p>Note not found</p>

<?php endif; ?>

###All Returns an array containing all currently set notes. Returns FALSE if notes cannot be found. The notes are automatically deleted after they are accessed.

$notes = note::all();

By setting an optional first argument, you can specify a regex pattern to which notes must match in order to be returned. Only the notes that match the pattern will be deleted after they are accessed.

$notes = note::all('/^on/');

###Delete

Deletes a note with a given name:

note::delete('one');