diff --git a/Documentation/Global/FlashMessages.rst b/Documentation/Global/FlashMessages.rst index 89e1944..320983b 100644 --- a/Documentation/Global/FlashMessages.rst +++ b/Documentation/Global/FlashMessages.rst @@ -7,77 +7,110 @@ FlashMessages ViewHelper `` ============================================ +This ViewHelper renders the `Flash messages `_ +(if there are any) as an unsorted list. + +.. figure:: /Images/FlashMessageExamples.png + :alt: Screenshot of two flash message one with success and one with warning severity + + Example for the output of flash messages in an Extbase plugin + .. typo3:viewhelper:: flashMessages - :display: tags,description,gitHubLink,arguments + :display: tags,gitHubLink :source: ../Global.json + :noindex: -.. _typo3-fluid-flashmessages-example: +.. contents:: Table of contents -Examples -======== +.. _typo3-fluid-flashmessages-example-simple: -Simple ------- +Quick start: Simple flash message output +======================================== -:: +You can use the following tag within any Extbase template: - +.. code-block:: html + :caption: packages/my_extension/Resources/Private/Templates/Something/DoSomething.html -A list of flash messages. + -TYPO3 core style ----------------- +It displays the flash messages with a standard bootstrap compatible layout. -:: +.. _typo3-fluid-flashmessages-extbase: - +Adding and displaying flash messages in Extbase +=============================================== -Output:: +Within an Extbase `controller `_ +(extending :php-short:`\TYPO3\CMS\Extbase\Mvc\Controller\ActionController`) you +can call method `addFlashMessage()` to add flash messages to the message queue: -
-
-
-
- - - - - - - -
-
-
Info - Title for Info message
-

Message text here.

-
-
-
-
+.. literalinclude:: _FlashMessages/_MyController.php + :caption: packages/my_extension/Classes/Controller/MyController.php -Output flash messages as a description list -------------------------------------------- +As mentioned above, they will be displayed when a `` is displayed within any action +of the same controller: -:: +.. literalinclude:: _FlashMessages/_DemonstrateFlashMessages.html + :caption: packages/my_extension/Resources/Private/Templates/My/DemonstrateFlashMessages.html - -
- -
{flashMessage.code}
-
{flashMessage.message}
-
-
-
+If you want to display the flash messages in any place outside of the controller +you can use the identifier `extbase.flashmessages.`, for example: + +.. literalinclude:: _FlashMessages/_SomeForm.html + :caption: packages/my_extension/Resources/Private/Templates/Other/SomeForm.html + +.. _typo3-fluid-flashmessages-queueIdentifier: + +Using a specific flash message queue in plain classes +===================================================== + +When you use the FlashMessages ViewHelper outside of the Extbase context, +supplying the :ref:`queueIdentifier ` +is mandatory. + +When you add a message manually to the queue, you can specify an arbitrary +identifier: + +.. code-block:: php + + // private \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService; -Output:: + $messageQueue = $this->flashMessageService->getMessageQueueByIdentifier('myQueue'); -
-
1013
-
Some Warning Message.
-
+You can then display messages of only this one queue using the identifier: -Using a specific queue ----------------------- +.. code-block:: html -:: + - +.. _typo3-fluid-flashmessages-example: +.. _typo3-fluid-flashmessages-example-custom: + +Output flash messages with a custom layout +========================================== + +Using the argument :ref:`as ` +you can receive all flash messages in a variable and then handle the rendering +yourself within the `` tag: + +.. code-block:: html + :caption: packages/my_extension/Resources/Private/Templates/Something/DoSomething.html + + +
+ +
{flashMessage.code}
+
{flashMessage.message}
+
+
+
+ +.. _typo3-fluid-flashmessages-arguments: + +Argument of the FlashMessages ViewHelper +======================================== + +.. typo3:viewhelper:: flashMessages + :display: arguments-only + :source: ../Global.json diff --git a/Documentation/Global/_FlashMessages/_DemonstrateFlashMessages.html b/Documentation/Global/_FlashMessages/_DemonstrateFlashMessages.html new file mode 100644 index 0000000..e9a7a37 --- /dev/null +++ b/Documentation/Global/_FlashMessages/_DemonstrateFlashMessages.html @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Documentation/Global/_FlashMessages/_MyController.php b/Documentation/Global/_FlashMessages/_MyController.php new file mode 100644 index 0000000..ea87ae5 --- /dev/null +++ b/Documentation/Global/_FlashMessages/_MyController.php @@ -0,0 +1,18 @@ +addFlashMessage('This is a success message.'); + $this->addFlashMessage('This is a warning.', 'Warning Headline', ContextualFeedbackSeverity::WARNING); + return $this->htmlResponse(); + } +} diff --git a/Documentation/Global/_FlashMessages/_SomeForm.html b/Documentation/Global/_FlashMessages/_SomeForm.html new file mode 100644 index 0000000..0f6a65a --- /dev/null +++ b/Documentation/Global/_FlashMessages/_SomeForm.html @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Documentation/Images/FlashMessageExamples.png b/Documentation/Images/FlashMessageExamples.png new file mode 100644 index 0000000..5d9a6bc Binary files /dev/null and b/Documentation/Images/FlashMessageExamples.png differ