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]