f3 flash
1.0.2
這是一個小插件,可以添加簡單的閃存消息和閃光燈鍵,用於php無脂肪框架,版本3.x
方法1:使用作曲家作曲家需要ikkez/f3-flash
方法2:將flash.php文件複製到您的F3 lib/目錄或AutoLoader已知的其他目錄
要添加僅在下一個請求中僅在模板中顯示一次的消息(或多個),請執行:
Flash:: instance ()-> addMessage ( ' You did that wrong. ' , ' danger ' );
// or
Flash:: instance ()-> addMessage ( ' It worked! ' , ' success ' );並在模板中顯示這一點:
<!-- bootstrap style-->
< F3:repeat group =" {{ Flash::instance()->getMessages() }} " value =" {{ @msg }} " >
< div class =" alert alert-{{ @msg.status }} alert-dismissable " >
< button type =" button " class =" close " data-dismiss =" alert " aria-hidden =" true " > × </ button >
{{ @msg.text | esc }}
</ div >
</ F3:repeat >就是這樣。
如果需要,也可以添加簡單的密鑰:
$ flash = Flash:: instance ()
$ f3 -> set ( ' FLASH ' , $ flash );
$ flash -> setKey ( ' highlight ' , ' bg-success ' ); // with value
$ flash -> setKey ( ' show-hint ' ); // without returns just TRUE
$ flash -> setKey ( ' error ' , ' Catastrophic error occured! ' );對於以下用例
< div class =" box {{ @FLASH->getKey('highlight') }} " >
< F3:check if =" {{ @FLASH->getKey('show-hint') }} " >
< p > It's new !!! </ p >
</ F3:check >
...
</ div > < F3:check if =" {{ @@FLASH && @FLASH->hasKey('error') }} " >
< p > {{ @FLASH- > getKey('error') }} </ p >
</ F3:check > 您可以根據GNU通用公共許可證版本3或更高版本使用此插件。
版權(C)2017 Christian Knuth [Ikkez]