Jump to content

Show Notices in ProcessWire Modal


kongondo
 Share

Recommended Posts

Not sure I understand what you mean, but the native notices do appear regardless of whether an admin page is viewed in a modal (?modal=1) or not.

Or do you mean you want to prevent the notices from appearing normally and open a modal window that only displays the notices?

Link to comment
Share on other sites

Hmm. They've never showed up for me. What I want is for notices to show up as normal when I save, regardless of whether I am in a modal or a normal window. When I save any page in a modal (e.g. try editing a page in Batcher or a post in Blog) or when I edit and save any custom module page (e.g. some settings page in Media Manager)  in a modal and call $this->message() or $this->error(), they never get shown. 

Link to comment
Share on other sites

4 minutes ago, kongondo said:

When I save any page in a modal (e.g. try editing a page in Batcher or a post in Blog) or when I edit and save any custom module page (e.g. some settings page in Media Manager)  in a modal and call $this->message() or $this->error(), they never get shown.

That's strange. I didn't test with real modals (just appended "modal=1" to the urls) but see the screenshots below of Page Edit and a module config.

2016-12-18_103531.png2016-12-18_103409.png

Maybe something is different when the page is really inside a modal.

Link to comment
Share on other sites

4 minutes ago, kongondo said:

System Notifications notices don't show up when in a modal.

Yeah, looks like the extra markup isn't appended when the modal GET variable is present.

https://github.com/processwire/processwire/blob/35df716082b779de0e53a3fcf7996403c49c9f8a/wire/modules/System/SystemNotifications/SystemNotifications.module#L113-L115

  • Like 1
Link to comment
Share on other sites

Yeah, ta. But that means I can't use System Notifications. It reverts to the old notifications. It also means that I need to tell users of my module to have that setting off (Leave them alone) if they want to see notices in modals. Not great. Anyway, thanks guys. Currently, I am using a custom jQuery solution to show notices in modals....but still curious why System Notifications is turned off in modals

Link to comment
Share on other sites

You could use a hook to override the decision not to show notifications in modals:

$this->addHookAfter('AdminTheme::getExtraMarkup', function($event) {
    if($this->input->get('modal')) {
        $this->modules->get('SystemNotifications')->hookAdminThemeGetExtraMarkup($event);
    }
});

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...