Hi, just wondering why Phalcon\Flash\Direct doesn't have an output() method like Phalcon\Flash\Session has?
|
Dec '20 |
11 |
3269 |
6 |
Hi, just wondering why Phalcon\Flash\Direct doesn't have an output() method like Phalcon\Flash\Session has?
@Phalcon But if i want to use Ajax, and i want to flash message indirectly. So what should i do? I have to write <div class="error alert"></div> myself.
No, you need to place {{ content() }} where you want to show the output generated in the latest render level.
I must say, using Phalcon\Flash\Session instead of the direct one has so many benefits.
Might be worth dropping the entire concept of direct flash, as it seems a bit useless in its current form?
I agree that this is a useful feature. Phalcon\Flash\Direct::output() method will not be superfluous. For example I can use output in the main layout, not in a view.
Add a NFR for this discussion https://github.com/phalcon/cphalcon/issues/629
I know this question is very old but I would like to add something that may be helpful to those who may land here.
If you are using Phalcon\Flash\Direct and want to flash messages from Actions where you are redirecting, use Dispatcher foward and not response redirect in order to get the output. And not forgeting {{ content() }} as Phalcon mentioned.
Thanks
@cnwggu You can change Phalcon\Flash\Direct to return the HTML instead of generate the output directly.
$flash = new Phalcon\Flash\Direct(); $flash->setImplicitFlush(false); echo $flash->error("this is an error");
works like a charm
Great article. We have an equally good article, please read:Combo Power Rack With Smith Machine Function Need a multifunction unit for full-body strength training? Yanre Fitness has the best power rack/smith machine combo for sale. Yanre is a self-design gym equipment manufacturer offering premium gym machines and fitness accessories for commercial use. We are proudly known as a leading supplier worldwide since 1997.