Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Webmaster BG3

    (@webmaster-bg3)

    I have found the solution by myself, so I like to post the answer for anyone who has the same problem.

    N.B. this work only on development version of Easy Fancybox. Get the plugin link at the end of the post

    1) Configure Nextgen effect for fancybox:
    Go to http://yoursite.com/wp-admin/admin.php?page=nggallery-options at tab “Effects”, select “Custom” as JavaScript Thumbnail effect and put this line of code in Link Code line

    class="fancybox" rel="%GALLERY_NAME%"

    2) Modify plugin code to get ajax pagination for custom effect:
    Open the file wp-content/plugins/nextgen-gallery/nggallery.php and locate this block of code:

    // Load AJAX navigation script, works only with shutter script as we need to add the listener
    if ( $this->options['galAjaxNav'] ) {
    	if ( ($this->options['thumbEffect'] == "shutter") || function_exists('srel_makeshutter') ) {
    		wp_enqueue_script ( 'ngg_script', NGGALLERY_URLPATH . 'js/ngg.js', array('jquery'), '2.1');
    		wp_localize_script( 'ngg_script', 'ngg_ajax', array('path'		=> NGGALLERY_URLPATH,
    															'callback'  => trailingslashit( home_url() ) . 'index.php?callback=ngg-ajax',
    															'loading'	=> __('loading', 'nggallery'),
    		) );
    	}
    }

    Modify the code to be like this:

    // Load AJAX navigation script, works only with shutter script as we need to add the listener
    if ( $this->options['galAjaxNav'] ) {
    	if ( ($this->options['thumbEffect'] == "shutter") || function_exists('srel_makeshutter') ) {
    		wp_enqueue_script ( 'ngg_script', NGGALLERY_URLPATH . 'js/ngg.js', array('jquery'), '2.1');
    		wp_localize_script( 'ngg_script', 'ngg_ajax', array('path'		=> NGGALLERY_URLPATH,
    															'callback'  => trailingslashit( home_url() ) . 'index.php?callback=ngg-ajax',
    															'loading'	=> __('loading', 'nggallery'),
    		) );
    	}
    	else if ( ($this->options['thumbEffect'] == "custom") || function_exists('srel_makeshutter') ) {
    		wp_enqueue_script ( 'ngg_script', NGGALLERY_URLPATH . 'js/ngg.js', array('jquery'), '2.1');
    		wp_localize_script( 'ngg_script', 'ngg_ajax', array('path'		=> NGGALLERY_URLPATH,
    															'callback'  => trailingslashit( home_url() ) . 'index.php?callback=ngg-ajax',
    															'loading'	=> __('loading', 'nggallery'),
    		) );
    	}
    }

    Now open the file wp-content/plugins/nextgen-gallery/js/ngg.js and locate the line:

    shutterReloaded.init('sh');

    You must found two occurrence in Nextgen Gallery 1.9.12. Change the code like this for both occurrence:

    //shutterReloaded.init('sh');
    easy_fancybox_handler();

    That’s all! Now you have Ajax pagination and Easy Fancybox working together.

    Warning: the modification i suggest will broke the default shutter effect, because I commented out it’s call. Another problem is that you could have some error if you uninstall or disable Easy Fancybox. So it need to be hardened if you want a safe code

    My setup:
    – WordPress 3.5.1
    – Easy Fancybox 1.5.0dev11 from http://downloads.wordpress.org/plugin/easy-fancybox.zip
    – Nextgen Gallery 1.9.12

    Hope to be helpful

    Hi BG3, absolutely fantastic! Thanks for sharing your work 🙂

    I hope this remains valid with the new 1.5 release…

    Thread Starter Webmaster BG3

    (@webmaster-bg3)

    Updated today. Everything sounds good with 1.5 release.

    Just wanted to say thanks for this! Worked flawlessly. 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘got fancybox working with ajax pagination in nextgen’ is closed to new replies.