Results 1 to 1 of 1

Thread: Display Success and Failure Messages

  1. #1
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,861
    Blog Entries
    88
    Thanks
    485
    Thanked 809 Times in 528 Posts

    Default Display Success and Failure Messages

    Hotaru has functions which fade in a red or green div with a given message on it. There are three ways to display messages:

    Show a single message

    Longhand:


    PHP Code:
    $h->message "This is a message";
    $h->messageType "green";
    $h->showMessage(); 
    messageType can only be "green" or "red".

    Shorthand:

    PHP Code:
    $h->showMessage("This is a message""green"); 
    The default messageType is "green" anyway, so you can omit it from the function call if you like.


    Show multiple messages

    You can repeat the above to show multiple messages, but problems arise if you assign messages before loading a page, but want to show them later within the body of a page. In that case, only the last message will be shown. The solution is to store them in an associative array like this:

    PHP Code:
    $h->messages['This is a success message'] = "green";
    $h->messages['This is an error message'] = "red";

    $h->showMessages(); 
    Notice that we're using messages in our array name and function call.
    Last edited by Nick; 01-06-2010 at 02:37 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •