[TYPO3-mvc] Display a session-stored flash message on a cached controller action page after a redirect

Franz Koch typo3.RemoveForMessage at elements-net.de
Fri Jun 25 09:17:59 CEST 2010


Hey,

> The user clicks on 'Put product into the basket.'.
> When clicked, the user is redirected to the basket.
> The basket stores the product and saves a flash message.
> The user is now beeing redirected to the previous page. (Referer)
> The refering page is beeing displayed without the flash message.
> The message will get rendered only on the next visited uncached page.
>
> Is there a way to render the flash message without clearing the cache?
> Or is there even a way to display it, with clearing the cache?

If you would clear the cache and still render a cacheable version of 
your plugin, then the flashmessage will become part of the new cached 
page - so that's not an option.


The only "clean" solution I see is something like Christian suggested. 
Let your "addToBasket"-Action actually display a info message and add a 
timed redirect to it.

Another way would be to add a second instance of your plugin on your 
products page which is USER_INT - but this will somewhat slow down 
overall rendering.

The second and last way I see (although never tried something like this) 
would be to hook into a very early stage in page rendering, check there 
for some flashMessages in your session and have those added by some 
small piece of code, by either adding some JS stuff to the pageHeader or 
by postProcessing the page from Cache and preg_replace some (by default 
invisible) HTML markup. This might be the fastest solution if it's 
working (which it should).

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list