Session-flash() and history.back

2006-12-20 Thread Martin


According to the documentation in
http://wiki.cakephp.org/tutorials:flashing I made a site using flashing
to give messages or alerts to users. It works ok, but the problem is
comes when the user goes back (through   the browser's back button) and
goes forward (also through the browser's button), the message comes
again.
I tried removing the div from the DOM object via js after showing the
message but it has the same efect, the message going back and forward,
it cames again
I also try deleting the session variable with no effect

in my layout
if ($this-controller-Session-check('Message.flash'))
{
   $this-controller-Session-flash();
$this-controller-Session-del('Message.flash');
}

Does some one know how to solve this problem, how to show ONLY ONCE the
flash message using back and forward button of the browser.

Regards

MARTIN

PD: this way of doing
$this-controller-Session-flash(); in the layout does not work with
the last version of framework.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Session-flash() and history.back

2006-12-20 Thread [EMAIL PROTECTED]


It seems like you are having a problem with the browser caching the web
pages.  You might be able to adjust the header sent to the browser so
it does not cache.

Another approach would be to use a asynchronous update to display the
flash message, instead of the standard way.

To do that, add this method to your app_controller.php


function asynch_flash()
{
 $this-layout = 'ajax';
 $this-render('../pages/asynch_flash');
}

Add the following code to a file asynch_flash.thtml in your
app/views/pages/ directory

?php
if ($session-check('Message.flash'))
{
 $session-flash();
}
?

And to your layout file add the following in place of the usual flash
output

div id=flash
script type=text/javascript
?php $cont = $this-params['controller']?
new Ajax.Updater(flash, '?php echo
$html-url(/$cont/asynch_flash/)?');
/script
/div

That should do it, although it might look funny with debug on.

Hope that helps.

-- Russell


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---