Message-ID: <2007756301.378864.1711677313514.JavaMail.root@confluence-doc2-production> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_378863_1775208851.1711677313510" ------=_Part_378863_1775208851.1711677313510 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Throughout the whole front office, the customer can receive noti= fication messages from PrestaShop, to inform her about successes or errors = for instance. Your theme can too send notifications when certain events occ= ur.
The notification messages are not hardcoded in the template files, but a= re sent from the controller, so that you have consistency in case you updat= e/change your theme. Also, this way there is a better chance that all notif= ication messages are already translated into your language!
An array of notification is passed to the templates, containing at least= one of these:
success | An action was performed and everything went well= . |
error | Something went wrong. |
warning | Important notice the merchant should know about.= |
info | =E2=80=9Cjust so you know=E2=80=9D. |
In the Starter Theme, notifications are implemented as a partial template f= ile:
<asid= e id=3D"notifications"> <div class=3D"container"> {if $notifications.error} <article class=3D"alert alert-danger" role=3D"alert"> <ul> {foreach $notifications.error as $notif} <li>{$notif}</li> {/foreach} </ul> </article> {/if} {if $notifications.warning} <article class=3D"alert alert-warning" role=3D"alert"> <ul> {foreach $notifications.warning as $notif} <li>{$notif}</li> {/foreach} </ul> </article> {/if} {if $notifications.success} <article class=3D"alert alert-success" role=3D"alert"> <ul> {foreach $notifications.success as $notif} <li>{$notif}</li> {/foreach} </ul> </article> {/if} {if $notifications.info} <article class=3D"alert alert-info" role=3D"alert"> <ul> {foreach $notifications.info as $notif} <li>{$notif}</li> {/foreach} </ul> </article> {/if} </div> </aside>=20
=E2=80=A6and are then included in the template file:
{block n= ame=3D'notifications'} {include file=3D'_partials/notifications.tpl'} {/block}=20
Your front controller holds the 4 following variables:
$this->error
$this->success<=
/span>
$this->warning<=
/span>
$this->danger=
span>
They are PHP arrays, and they hold messages as a string.
Since PrestaShop 1.7, you can redirect the customer AND display a = message after an action.