Jump to content
Mikepo

modal info popup

Recommended Posts

This modal is a pain in the &*&*, would not work well when using bootstrap modal-sm, so just used some css to do it.

<style>
#popupModal, .modal { 
        margin-left:<?php echo MODULE_CONTENT_FOOTER_POPUP_MARGIN_LEFT ?>!important; 
    } 
#popupModalc, .modal-content { 
        width:<?php echo MODULE_CONTENT_FOOTER_POPUP_WIDTH ?>!important; 
    height:auto!important;
  } 
</style>

Just add the controls in to the class file.

set in admin,

image.png.32bad0dbab1648eb2cb6dc80fd2cd721.png

you get

image.thumb.png.a4177c9403dc62558b24df72258e8b2f.png


 

Share this post


Link to post
Share on other sites

For those of you that have reported success with @Mikepo's version for Frozen, did you install it on the last Frozen release (2018-05-18)? I'm trying it, but after copying over all the files, and updating template_bottom.php per instructions, nothing happens. There is nothing in the admin Tools menu (expecting Popup Manager to be added), nor any other box (including Modules), and nothing offering to install it. The structure of things seems a bit different than other items in the Tools menu, so I'm wondering if this was actually built for an earlier version of CE? I have some ideas of where it might need changes, but before I spend more time on it, can you assure me that it does (or does not) work on a stock (+ patches) "Frozen" installation?

Share this post


Link to post
Share on other sites

That's the May 18 (2018) Frozen, and definitely not something earlier or later? According to the instructions, simply copying over the files (and one update) should produce a new entry in Tools menu, but I'm not seeing it. I'll double check my work one more time, then have to start serious debugging.

Share this post


Link to post
Share on other sites

@MrPhil I'm away from my desk at the moment, but I can assure you the package was used for the stock CE version, dated May 2018. Please check again, I can only help on my return.

Mike


osC BS gold live - osC CE in development (awesome)

Share this post


Link to post
Share on other sites
3 hours ago, MrPhil said:

(and one update)

don't remember doing any file update? Simply copy files over and and install footer , go to admin and setup popup.

Try these files of my BS4 site so you may have to mess about with the html a bit.

BS modal info popup layer.zip


 

Share this post


Link to post
Share on other sites
Posted (edited)

includes/template_bottom.php requires some code added just before </body>.  I will take a look at your files and see if there's anything different, or if it looks like it "fits" better.

Update:

  • You have a German word (?) in admin/includes/languages/english/popup_manager.php: 'Erfolg: change to 'Success:
  • includes/template_bottom.php code (in original, that you removed) appears to duplicate code in tpl_cm_footer_popup.php, so I commented the added code out of template_bottom
  • includes/languages/english/modules/content/footer/cm_footer_popup.php change 'Add a info popup to 'Add an info popup

The rest of your changes looked appropriate. That done, no change in behavior. I compared files in Mike's and your zip files; the next step is a line by line compare against what's on the server, to see if something got corrupted during file transfer, or whatever. There are no new entries in any of the admin left column menus (at top level -- is what I'm looking for a level or two down?). When Tools > Popup Manager appears, will I have the opportunity to set MODULE_CONTENT_FOOTER_POPUP_CONTENT_WIDTH?

Edited by MrPhil

Share this post


Link to post
Share on other sites
Posted (edited)
On 5/9/2019 at 10:13 AM, JcMagpie said:

No need to edit template bottom this works fine to add script to template_bottom.


 <?php    
tep_session_register('popup');
 $oscTemplate->addBlock("<script>
    $(window).on('load',function(){
        $('#popupModal').modal('show');
    });
</script>", 'footer_scripts');
  }
?>

No editing required of any file.

 

Edited by JcMagpie

 

Share this post


Link to post
Share on other sites
Posted (edited)
8 hours ago, MrPhil said:

When Tools > Popup Manager appears, will I have the opportunity to set MODULE_CONTENT_FOOTER_POPUP_CONTENT_WIDTH?

No why would you be able to set footer width in tools? That is just for popup content managment.

You could add the width in the footer add-on but as it's a modal not sure what the point would be.

I have added some modal control to my code to let me set modal display as required. This may be required if you have other modals running.

As stock any display width will be down to modal body content and modal class used.

image.png.a3e9c91d55a3754b6e76ae874c2836fa.png

Edited by JcMagpie

 

Share this post


Link to post
Share on other sites

I got it working after comparing every file line-by-line. Something got munged moving the JS code in and out of template_bottom and other places. In the process, I found a few minor glitches:

  1. admin/includes/languages/english/popup_manager.php   line 27 indefinitely.. -> indefinitely.   line 49 glag -> flag
  2. admin/popup_manager.php  line 182  why is po.popups_id in the SELECT twice? Should one of them be pod.popups_id? I see pod.popups_id = po.popups_id in the WHERE clause. It seems to work as-is, but I think later versions of MySQL may get upset that pod.popups_id isn't listed in the SELECT clause.
  3. admin/popup_manager.php  line 228 includes class="ckeditor" on a textarea. I don't think that CKEditor is built in to Frozen. Is it harmless to leave it in that class, and you get some benefit if you happen to install CKEditor?
  4. includes/languages/english/modules/content/footer/cm_footer_popup.php   line 4  one every page -> on every page
  5. includes/modules/content/footer/cm_footer_popup.php  line 22  function cm_footer_popup(   ->  function __construct(
  6. install.txt  is misleadingly simple. After copying in the files, you need to go to Admin > Modules > Boxes > available boxes to install and order it to install the Popup Manager (or whatever it's called... it's gone now). You might note that nothing will show up in the installed Boxes list -- it goes into the Tools menu.

Thanks to the (late) De Dokta, Mike, and Zahid  for their work on this.

My client wants two things:

  1. Not only have a Close button, but also to automatically go away after 10 seconds. Does adding this after   $('#popupModal').modal('show'); in includes/modules/content/footer/templates/tpl_cm_footer_popup.php
       // disappear after 10 seconds
        setTimeout(function() {
          $('#popupModal').modal('hide');
        }, 10000);

    look like it would do the job? Since popups would have varying amounts of information, maybe the time delay (10 seconds here) should be a parameter in the popup database entry. '0' second delay would mean "don't go away until explicitly dismissed" (and should be the default).

  2.  

    Does this work cleanly on small devices? I'm wondering if a large image size would cause scrolling on a phone. I don't think customers would be pleased to have an important message disappear before they're done scrolling around the read the whole thing! Maybe it would be better just to stick to the Close button.

Share this post


Link to post
Share on other sites
4 hours ago, MrPhil said:

setTimeout(function()

Is not stable on bootstrap modal, will work but depending on page load you may find modal is triggered again. This works better on alert.

 

4 hours ago, MrPhil said:

Does this work cleanly on small devices?

Modals work fine on all devices, content is upto you, you need to make sure any  image used is responsive.


 

Share this post


Link to post
Share on other sites
25 minutes ago, JcMagpie said:

Is not stable on bootstrap modal,

Was wrong! will work if applied properly. Worked like this.

tep_session_register('popup');
 $oscTemplate->addBlock("<script>
   $(window).on('load',function(){
        $('#popupModal').modal('show');
setTimeout(function() {
    $('#popupModal').modal('hide');
}, 5000);
    });
    </script>", 'footer_scripts');

 


 

Share this post


Link to post
Share on other sites

I've run into problems with the popup manager. It would only edit or delete the first popup listed. I traced this to confusion in the code over when to use 'pID' and when to use 'popups_id' in the URL Query String (input and output -- it was a mixture of both). Basically, all popups_id= in building an href have to be changed to pID=, all $_GET['popups_id'] change to $_GET['pID'], and all '&pID=' in building a UQS apparently have to be just 'pID='. Leave $_POST['popups_id'] alone. Using pID consistently to mark which is the selected popup (for editing or deletion) seems to work.

I'm still having problems with expired popups remaining active. Looking through the code, it looks like it is very confused in how it's implemented, like someone started with one train of thought and changed back and forth. For instance, the date_scheduled and expires_date get set to NULL, but status is still 1 (so it keeps being displayed). I'm not sure this setting the date fields to NULL when changing status was thought through all the way. I also have popups with a future expiration date having their expires_date field cleared to NULL for no apparent reason (possibly when clicking the "Activate" green button).

I propose to change things a bit. status=0 would mean "not desired to be shown (by owner)", and status=1 would mean "desired to be shown". Instead of only 0 or 1 popups with status 1, any number could be 1. In cm_footer_pop_up.php, instead of playing with status when start/end dates are explicitly given, just loop through each status=1 popup (ordered by date_added, descending order). Check if date_scheduled (start) is NULL (started long ago) or in the past AND expires_date (end) is NULL or in the future, and output this popup. In popup_manager.php, the green/red light status change simply changes status to 0 or 1 for this one popup (doesn't affect others). The popups are again ordered by date_added, descending order. So, the first popup encountered in a specific order (most recently added to least) where status=1 (desired to show) and it falls within the given start/end dates, will be run. If an undesired one runs, the owner would have to temporarily deactivate the offending popup. In both cases, if expires_date is found to be in the past, status will be forced to 0. In neither case will start/end dates be changed to NULL.

I think that this behavior would be closer to what a user would intuitively expect to see. What do you think (especially @Mikepo and @JcMagpie)? If Mike wants to update his add-on with the revised code, I can send it as a zip file once I've tested it and am happy with the behavior.

Share this post


Link to post
Share on other sites

Not had any problems got several popup all can be edited with not issues. Auto switching between popups by set date worked fine for me. Set up with 2 languages in BS4 Frozen in time................................................................... 😊 no spoons or forks just a snapshot in time.

image.thumb.png.56129f31060f320f3e4d9cd372f45658.png


 

Share this post


Link to post
Share on other sites

just tested my live site, and multiple popups can be created and edited.  Only one popup can be active at any one time, as designed. I'm using CE frozen as of May 2018.

Not too sure where the problem lies as @MrPhil describes, as the addon works for me.


osC BS gold live - osC CE in development (awesome)

Share this post


Link to post
Share on other sites

I could create multiple popups with no problem. However, when I tried to edit or delete any of them (after selecting that row), it always acted on the first entry. The fix was to stop using a random mess of pID and popups_id in the URL Query String, and consistently use pID. Have you tried editing or deleting the second or third popup? Does it process the right one for you?

Share this post


Link to post
Share on other sites

Tested on early edge BS3 site just to be sure and still works fine no issues, can add, select and edit any popup with no issues.

image.thumb.png.d866fa801017800966b41236a02e83f3.png


 

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

×