Viewing 22 posts - 1 through 22 (of 22 total)
  • Author
    Posts
  • #1337264

    Dear Support-Team,

    I have searched the forums and tried a few things already. Also made some experiments with ?iframe=true. None of them worked. So the question to you professionals: Is it possible to use a lightbox in the blog post element?

    I have very short posts that are loaded if a link is klicked. It would be much more comfortable to just open them in a lightbox and not always load a new page. However, by default, the post image and title link always link to a page. Can I change this somehow?

    Glad to get some information about this. Thanks a lot!

    Best regards,
    Daniel

    #1337402

    Hey spooniverse,

    Thank you for the inquiry.

    This option is not available out of the box, but it is possible. Unfortunately, creating this kind of functionality is beyond the scope of support. You may need look for external help such as hiring a freelance developer.

    // https://kriesi.at/contact/customization

    Best regards,
    Ismael

    #1337421

    show me a test page where you like to open those links in a lightbox.
    is it a page like this:
    https://kriesi.at/themes/enfold-2017/elements/blog-posts/
    or
    https://kriesi.at/themes/enfold-2017/blog/blog-default/
    And you want to open not the posts on a new page but as iframe in a lightbox?

    #1337459

    Hey Guenni007,

    it is not about the normal blog. I would like to use a ALB blog post element (as in your first link) and display posts of a certain category on a page with the option “blog grid”. If the image or title of the shown entries is clicked the posts should be loaded as iframe in a lightbox, correct. Any ideas?

    Thank you for your interest! And thanks Ismael for pointing out that it can be made somehow.

    All the best,
    Daniel

    #1337555

    you can see here on top of that page a masonry with portfolio links.
    If you click to open it – it will open that portfolio in a lightbox ( but the complete page )
    https://webers-testseite.de/lightboxes/
    Is it the way you like to have it?

    #1337558

    This is the way I would like to have it, yes! But with normal posts (not portfolio entries). And for some reason I would like to use the blog post element (not a masonry). Or can’t it be made with the blog post element?

    Thank you for your effort already!

    #1337562

    i gave to the alb element itself a custom-class ( in my case ) : open-in-lightbox

    then i put this to child-theme functions.php:

    function posts_iframe_popup() { 
    ?>
    <script type="text/javascript">
    (function($) {
    $(window).on('load', function(){
      $('.open-in-lightbox a.av-masonry-entry').magnificPopup({
        type:'iframe',
        mainClass: 'spezial-masonries',
      }); 
    
      $('.open-in-lightbox a.slide-image, .open-in-lightbox .slide-entry-title > a').magnificPopup({
        type:'iframe',
        mainClass: 'spezial-blogposts',
      }); 
    
    });
    })(jQuery);
    </script>
    <?php }
    add_action('wp_footer', 'posts_iframe_popup');

    the mainClass is only to have a way to select f.e. the iframe-scaler specifically for that usage – you will have that class on mfp-wrap container.
    to have the links from both ( the image and the slide title – we have in that rule two selectors).

    PS : on that blog-posts the first link “iframe-lightbox” leads to an iframe which can open a new iframe on top :lol:

    #1337571

    Perfect! Thanks a lot, Guenni007!

    Any idea on how to hide the head and footer on those posts? In my case it is a custom post type. Should be possible with a modification to the single.php file of the CPT – what do you think?

    Even better would be a script to hide head and footer only if the entry is shown inside an iframe? Do you think that is possible?

    Best regards,
    Daniel

    #1337579

    try:

    function posts_iframe_popup() { 
    ?>
    <script type="text/javascript">
    (function($) {
    	if (top === self) { 
    		// no frame
    	} else { //frame 
    		$('#header, #footer, #socket').hide();
    		$('#main').attr('style', 'padding-top: 0px !important');  
    	};
    	
    	$(window).on('load', function(){
    	  $('.open-in-lightbox a.av-masonry-entry').magnificPopup({
    	    type:'iframe',
    	    mainClass: 'spezial-masonries',
    	  }); 
    
    	  $('.open-in-lightbox a.slide-image, .open-in-lightbox .slide-entry-title > a').magnificPopup({
    	    type:'iframe',
    	    mainClass: 'spezial-blogposts',
    	  }); 
    	});
    })(jQuery);
    </script>
    <?php }
    add_action('wp_footer', 'posts_iframe_popup');

    see testpage: https://webers-testseite.de/lightboxes/

    #1337580

    if you like to have no sidebar on the iframe replace that part above that checks if frame or not with:

    	if (top === self) { 
    		// no frame
    	} else { //frame 
    		$('#header, #footer, #socket, .sidebar').hide();
    		$('#main').attr('style', 'padding-top: 0px !important'); 
    		$('.container .av-content-small').css('width', '100%');
    		$('.content').css('border-right', 'none');
    	};

    and if you like to have the link of the concerning categorie aswell open in a lightbox – extend the selectors to:

    $('.open-in-lightbox a.slide-image, .open-in-lightbox .blog-categories > a,  .open-in-lightbox .slide-entry-title > a').magnificPopup({
    
    #1337598

    Wow! That is beyond my expectations. Thank you!

    Should be everything I need. Thread may be closed.

    #1337641

    Not for that –
    maybe you change from.hide() to .remove()
    that is somehow a matter of taste

    #1337678

    Why? What is your preference?

    #1337692

    the first only hides it (sets it to display: none), but it remains in the DOM – the second removes these containers. Nevertheless, the adjustment of the css (especially the padding-top) must still be done.

    #1337762

    Hi,

    Thanks for your help @Guenni007 :)

    Best regards,
    Yigit

    #1337802

    Dear @guenni007, last question: Do you think it is possible to load the script only for a certain viewport? Let’s say on mobile I would use a normal link (open the entry) and from tablet-size on I would load the script and use the added lightbox. Any ideas?

    #1337808

    should it be prevented for real mobile devices or for small screen sizes?
    If it is for small screen sizes is only to avoid ? it must respond to resize?

    #1337809

    try:

    function posts_iframe_popup() { 
    ?>
    <script type="text/javascript">
    (function($) {
    	if (top === self) { 
    		// no frame
    	} else { //frame 
    		$('#header, #footer, #socket').remove();
    		$('#main').attr('style', 'padding-top: 0px !important');  
    	};
    	
    	$(window).on('load', function(){
    	  $('.open-in-lightbox a.av-masonry-entry').magnificPopup({
    	    type:'iframe',
    	    disableOn: 768,
    	    mainClass: 'spezial-masonries',
    	  }); 
    
    	  $('.open-in-lightbox a.slide-image, .open-in-lightbox .slide-entry-title > a').magnificPopup({
    	    type:'iframe',
    	    disableOn: 768,
    	    mainClass: 'spezial-blogposts',
    	  }); 
    	});
    })(jQuery);
    </script>
    <?php }
    add_action('wp_footer', 'posts_iframe_popup');

    play with the 768 value to get what you like to have f.e.:
    if you take 769
    you have that case where an ipad mini (1024×768) will open on portrait the new page without lightbox – if you tilt it to landscape – it will open the lightbox.
    However, it will not undergo any change after the link is opened.

    #1337838

    Thank you! Works as aspected. Learnt a lot from your code.

    #1337881

    Hi,

    Great, I’m glad that @guenni007 could help you out :-)

    Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

    #1338039

    You may close this.
    And thanks again to Guenni007

    #1338048

    Hi,
    Glad Guenni007 was 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 22 posts - 1 through 22 (of 22 total)
  • The topic ‘Lightbox for Blog Post Element’ is closed to new replies.