Skip to content

Commit

Permalink
added FW_Flash_Messages
Browse files Browse the repository at this point in the history
  • Loading branch information
themefuse committed Mar 30, 2015
1 parent 8cf2d5d commit 249fce1
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions helpers/php.rst
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ Database

* ``fw_set_db_extension_data($extension_name, $key, $value)`` - extensions uses this function to store private values in the database.

.. _fw-form:

FW_Form
-------

Expand Down Expand Up @@ -664,4 +666,41 @@ Run the initialization script:
});
});
.. _fw-flash-messages:

FW_Flash_Messages
-----------------

You can display small messages that will be stored on the user's session for exactly one additional request.
This is useful when processing a form: you want to redirect and have a special message shown on the next page.
These types of messages are called "flash" messages.

.. _fw-flash-messages-add:

.. rubric:: Adding a flash message

.. code-block:: php
FW_Flash_Messages::add(
'unique-id',
__('Test message', 'fw'),
'success' // available types: info, warning, error, success
);
.. _fw-flash-messages-display:

.. rubric:: Displaying flash messages

In admin the messages are displayed as `admin notices <https://codex.wordpress.org/Plugin_API/Action_Reference/admin_notices>`__.

In frontend the messages are printed in footer,
then a javascript tries to find on the page the content container and move the messages in it.
This position guessing sometimes fails when the page has some special html structure
and the messages may not be visible or will be displayed in an inappropriate place.
You can choose a place in your template and display the messages manually:

.. code-block:: php
<?php if (defined('FW')) { FW_Flash_Messages::_print_frontend(); } ?>
.. include:: /links.rst.inc

0 comments on commit 249fce1

Please sign in to comment.