Jump to content
kongondo

Show Notices in ProcessWire Modal

Recommended Posts

Is it is possible to show native ProcessWire notices (errors and messages) in a PW modal (pw-modal) or alternatively on inputs in that modal?

Thanks.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
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. 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

I need to test with the older/original PW notifications then. See below for test with the 'new' System Notifications module: Normal window notices show up OK; modal window ones do not show up at all.

 

normal_window_save_notice.gif

modal_window_save_notice.gif

Share this post


Link to post
Share on other sites

Yep...That was it. System Notifications notices don't show up when in a modal. The 'normal/older' notifications show up OK in a modal.

  • Like 1

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

You can tell system notifications to skip session notifications and show only ajax ones as "popups".

  • Like 1

Share this post


Link to post
Share on other sites
47 minutes ago, kongondo said:

I can't seem to find that setting

This one maybe?

2016-12-18_121349.png

  • Like 1

Share this post


Link to post
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

Share this post


Link to post
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);
    }
});

 

Share this post


Link to post
Share on other sites

I'd imagine, that's because system notifications would run in the main window as well as in the modal at the same time, because of it's ajax functionality. That's most likely not the result one does hope for.

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By SwimToWin
      I have a nested page structure that fails for users without superuser permissions:
      Works for superusers / non-superusers:
          - foo
          -- bar
          --- page (status: published)
          ---- page (status: published)
          --- page (status: published)
      Fails for non-superusers (Works for superusers):
          - foo
          -- bar
          --- page (status: published)
          ---- page (status: published)
          --- page (status: unpublished <- apparently the template structure fails when there's one unpublished page)
      Template:
      <?php foreach ($page->children('include=all') as $p): #Fails for non-superusers ?> <?=$p->render()?> <?php endforeach; ?>     a) Works for non-superusers when I grant Page Edit permissions (on the template) to their assigned role/s.
          b) When I remove 'include=all' or 'include=unpublished' then it also works for non-superusers:
      <?php foreach ($page->children() as $p): #Works for non-superusers ?> <?=$p->render()?> <?php endforeach; ?> Error message (non-superusers)
          Internal Server Error
              The server encountered an internal error or misconfiguration and was unable to complete your request.
              Error has been logged.
          /www/site/assets/logs/errors.txt
              /foo/bar/baz/    Error:     Exception: Page '/foo/bar/baz/quz/' is not currently viewable.
          /www/site/assets/logs/exceptions.txt
              /foo/bar/baz/    Page '/foo/bar/baz/quz/' is not currently viewable. (in /wire/modules/PageRender.module line 410)
      Debug (non-superusers)
          Error: Exception: Page '/foo/bar/baz/quz/' is not currently viewable. (in wire/modules/PageRender.module line 410)
          #0 wire/core/Wire.php (397): PageRender->___renderPage(Object(HookEvent))
          #1 wire/core/WireHooks.php (823): Wire->_callMethod('___renderPage', Array)
          #2 wire/core/Wire.php (465): WireHooks->runHooks(Object(PageRender), 'renderPage', Array)
          #3 wire/core/WireHooks.php (924): Wire->__call('renderPage', Array)
          #4 wire/core/Wire.php (465): WireHooks->runHooks(Object(Page), 'render', Array)
          #5 site/templates/template.php (191): Wire->__call('render', Array)
       
    • By FireWire
      Hey all. I'm having an issue with the new custom page classes feature which is a fantastic tool.
      I am running into a recursion issue when attempting to call a custom page class. I have a class called BlogPostPage.php (for blog-post.php) which contains a method called getSummary(). That method gets a summary field or truncates the body in it's absence. I've attached photos of the template code, custom page class code (which I've simplified for testing), and the PW output error.
      There is no recursion in the getSummary() method. This error occurs whether I output multiple blog posts in a loop or if I output one blog post with no looping in my template code.

      In use:
      ProcessWire 3.0.164 dev
      PHP 7.3.13

      I am also using the Template Engine Twig module which has not caused any errors or issues thus far.
      Many thanks!



    • By neonwired
      I'm hoping someone has seen this before. There doesn't appear to be an issue with the user info.

       

    • By EyeDentify
      Hello Dear PW Gurus.

      Hope you fair well in these Corona Crisis times.

      Anyhow, i have a problem with a Cryptic error message that shows up when i am trying to Delete images out of a Images field.
      The Error message does say a little but it does not make sense to me why i can´t delete the images because of it.

      Is it some permission issue perhaps?

      I will attach screenshots of it and what i did prior to it.
      I am from sweden so ignore the funny words here and there.

      Hope you all can send me on the right track.
      i am running PW 3.0.139 on this install.

      Step1:

      Step 2: Select the images with the trashcan symbol

       
      Step 3: Cryptic Error message

      I am scratching my head on this one, have not seen this before.

      Thankfull for all help.
      /EyeDentify
    • By Entil`zha
      Hi,
      For some reason when I try to read and clear messages or errors in template I'll get the messages but they won't clear and will show after next page load.
      I following code in my head.inc which is included in every template.
      $messages = $wire->messages('clear all'); foreach ($messages as $m) { echo '<div class="alert alert-success alert-dismissible" role="alert">'; echo '<p class="badge badge-pill badge-success">OK</p> ' . $m->text; echo '<button type="button" class="close" data-dismiss="alert" aria-label="Close">'; echo '<span aria-hidden="true">&times;</span>'; echo '</button>'; echo '</div>'; } I'll get all the messages but they don't get cleared.
      Only way to clear messages is to load page from admin area.
       
×
×
  • Create New...