twols Posted July 29, 2016 Share Posted July 29, 2016 Hello, guys! I'm trying to display the list of notices, but unfortunately there are more informations that I would like to show: Quote You was successfully logged out! Compiled file: /site/templates/logout.php <- how can I filter this?? The class of the notice seems to be always 'Session'. But sometimes also 'FileCompiler'.. Here is the code: <?php if(count(ProcessWire\wire('notices'))): ?> <div id="messages"> <?php foreach (ProcessWire\wire('notices') as $notice): ?> <?php if($notice->class != 'Session') { continue; } if ($notice instanceof NoticeError) { $class = "error"; } else { $class = "information"; } ?> <div class="<?php echo $class; ?> <?php echo $notice->class; ?>"><?php echo $notice->text; ?></div> <?php endforeach; ?> </div> <?php ProcessWire\wire('session')->removeNotices(); ?> <?php endif; ?> Link to comment Share on other sites More sharing options...
Robin S Posted July 30, 2016 Share Posted July 30, 2016 You can filter the notices with a hook before Page::render in /site/ready.php The file compiler notices are useful information so probably sensible to filter these notices only for non-superusers. $this->addHookBefore('Page::render', function($event) { $user = $this->user; if(!$user->isSuperuser()) { $notices = $this->notices; $notices->not("class=FileCompiler"); $notices->not("text~=Compiled file"); } }); 3 Link to comment Share on other sites More sharing options...
AndZyk Posted July 31, 2016 Share Posted July 31, 2016 You were successfully logged out Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now