1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Docs] Display Success and Failure Messages

Discussion in 'Developing Plugins' started by Nick, Jul 17, 2009.

  1. Nick

    Nick Well-Known Member

    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:
    $h->message "This is a message";
    $h->messageType "green";
    $h->showMessage();
    messageType can only be "green" or "red".

    Shorthand:

    PHP:
    $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:
    $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: Jan 6, 2010

Share This Page