X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=messages.php;fp=messages.php;h=8d8196d784c62317e8f9a1ac8ebb34c9cb2fd759;hb=d03e8554ee3e80a6333126e67dd4c20f54ec700e;hp=0000000000000000000000000000000000000000;hpb=1f787c4ef79ce26a5385bd325586e7796fadf8b4;p=wfpl.git diff --git a/messages.php b/messages.php new file mode 100644 index 0000000..8d8196d --- /dev/null +++ b/messages.php @@ -0,0 +1,91 @@ + section with ~message_text.html~ tag in it. +# +# If you want a divider (any text between message boxes when there are multiple +# boxes) provide a sub-template section named "message_divider" INSIDE +# "message_box" at the begining of it. +# +# If you'd like something around the group of all message boxes, you can put +# the whole thing in a sub-template section called "message_container" + +# Simple example: +# +# +#

~message_text.html~

+# + +# Full-featured example: +# +# +#
+# +# +#
+# +#

~message_text.html~

+# +#
+# + +require_once('code/wfpl/template.php'); + +function message($msg) { + if(!isset($GLOBALS['wfpl_messages'])) { + $GLOBALS['wfpl_messages'] = array(); + } + + $GLOBALS['wfpl_messages'][] = $msg; +} + +# if you want the messages in a template other than the default one, pass it like so: +# +# display_messages(ref($my_template)); +function display_messages($template = 0) { + $first = true; + if($template === 0) { + $template = &$GLOBALS['wfpl_template']; + } else { + $template = &$template->ref; + } + + if($GLOBALS['wfpl_messages']) { + foreach($GLOBALS['wfpl_messages'] as $msg) { + if($first) { + $first = false; + } else { + $template->sub('message_divider'); + } + $template->set('message_text', $msg); + $template->sub('message_box'); + } + $template->sub('message_container'); + } +} + +?>