Display a message on every page


Within a controller I want to work out if a user has validated their email address. If they haven’t (and are logged in) I want a message to display on every page telling them they need to validate their email address.

Best way to go about this ?

I don’t know if this is the best way, but you could use setstate to set a session variable (based on logic in your controller). Then in your main.php layout file include a div containing your message that conditionally gets added based on the value of the session variable. An alternative to displaying the conditional logic in your main.php is to write a widget that handles it all.

Just found if i put in beforeRender() in the Controller in components it lets me set some functionality there.

This good practice?