Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1429375

    Hello,
    I would like to open a Pop-Up/Lightbox with text on any type of link. If I click on a Button or an a link of my portfolio grid.
    Just like it would be a picture, but it’s just plain text (may with a picture inside the text block)
    How can I do this?

    Best regards

    • This topic was modified 10 months, 3 weeks ago by northorie.
    #1429407

    Hey northorie,
    To create a text box popup add this code to the end of your child theme functions.php file in Appearance ▸ Editor:

    function magnific_popup_with_no_scroll() { ?>
      <script>
    (function($) {
      $(window).on('load', function(){
        $('.open-popup-link').addClass('no-scroll');
        $('.open-popup-link').magnificPopup({
          type:'inline',
          midClick: true,
          callbacks: {
            beforeOpen: function () {
              $('body').css("overflow-y", "hidden");
            },
            close: function() {
              $('body').css("overflow-y", "auto");
            },
          },
        });
      });
      })(jQuery);
    </script>
      <?php
    }
    add_action( 'wp_footer', 'magnific_popup_with_no_scroll', 99 );

    Then on the page you want the popup to show on add this into a code block:

    <div id="open-popup" class="popup mfp-hide">
    <p>PLACE CONTENT HERE</p>
    </div>

    change the “PLACE CONTENT HERE” text to suit your needs, including adding a image.
    Then add this CSS in your Enfold Theme Options ▸ General Styling ▸ Quick CSS field:

    .popup {
    position: relative;
    background: #FFF;
    padding: 20px;
    width: auto;
    max-width: 500px;
    margin: 20px auto;
    }

    Here is an example with a image in the popup:
    Enfold_Support_4334.jpeg

    Best regards,
    Mike

    #1429462

    Thank you very much, it’s exactly what I want.

    But it doesn’t work properly yet.
    I placed the link inside the first box on the homepage.
    The popup opens, but without the styling.

    Further questions:
    1. How can I open this popup from a button
    2. How can I make the codeblock invisible on the page? I placed it at theend, just right above the footer, but there is a free space now

    Best regards

    • This reply was modified 10 months, 2 weeks ago by northorie.
    #1429463

    .

    • This reply was modified 10 months, 2 weeks ago by northorie.
    • This reply was modified 10 months, 2 weeks ago by northorie.
    #1429470

    Hi,
    As for the popup styling, it looks like I made an error in the snippet above, please change the popup code to this:

    <div id="open-popup" class="popup mfp-hide">
    <p>PLACE CONTENT HERE</p>
    </div>

    so the css will work correctly, I adjusted the code above.
    On your page it looks like you added the code block element after the grid row, so a new section was created, this space is not the code block it self, it has a height of zero. So try adding the code block in the grid row under the contact form.
    Or you can add this css:

    #after_grid_row_4 {
    	display: none;
    }

    Best regards,
    Mike

    #1429473

    Thank you Mike!
    The space at the bottom is gone an the popup appears propely :) I’m happy

    Last one: how can I use the popup on a button? I want the popup/lightbox to open, when a button is clicked

    • This reply was modified 10 months, 2 weeks ago by northorie.
    #1429477

    First – Mikes post is still right – but the need for the callback function is not necessary anymore – because there is now a filter for reaching the fixed background on lightbox opened.

    add_filter( 'avf_default_lightbox_no_scroll', '__return_true' );
    


    next:
    the code for that inline popup is correct but you had to know that the class open-popup-link had to be the trigger for the magnificPopup function.
    On button Element the custom class goes to the button wrapper – not the anchor itself. – so the selector had to reflect that ( the class is parent of the anchor)

    function inline_popup_every_avia_ID_you_like() { 
    ?>
    <script type="text/javascript">
    (function($){
    $(window).on('load', function () {
    	$('.open-popup-link').find('a').addClass('no-scroll');
    	
        $('.open-popup-link a').magnificPopup({
    		removalDelay: 500,
    		type:'inline',
    		midClick: true,
        });
    
        $(document).on('click', '.popup-modal-dismiss', function (e) {
          $.magnificPopup.close();
        });
    
     });   
    
    })(jQuery);
    </script>
    <?php 
    }
    add_action('wp_footer', 'inline_popup_every_avia_ID_you_like', 999);

    summary:

    • the trigger is a link which is child of the custom-class: open-popup-link
    • if you got a lot of these trigger links you can give that custom-class to the color-section etc. this indicates that all links inside goes to lightbox.
    • if you want to link to another lightbox from that modal window – just place a button inside again with class: open-popup-link
    • there is a second class – thats for a link inside the popup that could close the lightbox: popup-modal-dismiss
      nice to have for links in the lightbox that goes to an anchor link (f.e. one-pager sites).
    • the triggered link should have now a manual link to an anchor with unique ID
    • give to this element that goes to the lightbox the class mfp-hide (to make it invisible) and maybe the class white-popup (for prestyled styling of the lightbox by magnificPopup) and the ID of the button link
    #1429478

    Hi,
    To enable a button to open the popup, add a button to your page and set the link URL to #open-popup:
    Enfold_Support_4357.jpeg
    then go to Advanced ▸ Developer Settings and add the custom class open-popup-button:
    Enfold_Support_4359.jpeg
    then update the popup script in your child theme functions.php to this:

    function magnific_popup_with_no_scroll_and_button() { ?>
      <script>
    (function($) {
      $(window).on('load', function(){
    	$('.open-popup-button a').addClass('open-popup-link');
        $('.open-popup-link').addClass('no-scroll');
        $('.open-popup-link').magnificPopup({
          type:'inline',
          midClick: true,
          callbacks: {
            beforeOpen: function () {
              $('body').css("overflow-y", "hidden");
            },
            close: function() {
              $('body').css("overflow-y", "auto");
            },
          },
        });
      });
      })(jQuery);
    </script>
      <?php
    }
    add_action( 'wp_footer', 'magnific_popup_with_no_scroll_and_button', 99 );

    then you can use both text links and buttons for your popup like in the example:
    Enfold_Support_4361.jpeg
    Enfold_Support_4363.jpeg

    Best regards,
    Mike

    #1429483

    Awesome! Thank you so much!
    Now I have three buttons and each should open an own popup. I tried with a link to #open-popup2
    an addes this code inside the code block

    <div id="open-popup2" class="popup mfp-hide">
    <p>PLACE CONTENT HERE 2</p>
    </div>

    But no popup appears. What did I do wrong?

    It works on the text-link though, but not on the second button in the middle

    • This reply was modified 10 months, 2 weeks ago by northorie.
    #1429486

    Hi,
    On my test page I added two more buttons with the URLs #open-popup3 and #open-popup2
    Enfold_Support_4367.jpeg
    and adjusted the code blocks to match:
    Enfold_Support_4369.jpeg
    and they work correctly:
    Enfold_Support_4371.jpeg
    try checking your code again.

    Best regards,
    Mike

    #1429553
    This reply has been marked as private.
    #1429585

    Hi,
    It looks like you are not using the new code that I posted above that allows buttons to be used.
    It also looks like you didn’t add the custom class to the buttons for the new script to work, please review this thread again.

    Best regards,
    Mike

    #1429588

    Yes! I missed that – sorry. Now i’m happy :) Thanks again
    Thread can be closed.

    #1429592

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Pop-Up/LIghtbox’ is closed to new replies.