• Resolved s0what

    (@s0what)


    Hi!

    I have very large number of pages and I have very long navigation line.
    Could you please tell me, how to make something like this

    1 .. 55 56 57 58 59 60 61 62 63 .. 2000
    or
    << 55 56 57 58 59 60 61 62 63 >>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter s0what

    (@s0what)

    I guess nobody knows the answer ?? So I spent few hours coding and now I got modified function which does that and here it is:

    /**
     * Built-in pagination for galleries
     * Mod by SoWhat
     * @since 1.6.5.1
     */
    function file_gallery_do_pagination( $max_num_pages = 0, $page = 0 )
    {	
    
    $max_count = $max_num_pages;
    
    	if( 0 < $max_num_pages && 0 < $page )
    	{
    		$out = array();
    
    		remove_query_arg('page');
    
    	if ($max_count <= 10 || $page > $max_num_pages-10) { // if less then 10 pages or in the end
    		$ix=0;
    		while( 0 < $max_num_pages)
    		{ 	if ($ix > 10 && $page > $max_num_pages-10) break;
    
    			if( (int) $page === (int) $max_num_pages )
    				$out[] = '<span class="current">' . $max_num_pages . '</span>';
    			else
    				$out[] = str_replace('<a ', '<a class="page"', _wp_link_page($max_num_pages)) . $max_num_pages . '</a>';
    
    			$max_num_pages--; $ix++;
    		}
    		if ($max_count > 10) return '<div class="wp-pagenavi">' . "\n<a href='../1/'>1</a> .. ". implode("\n", array_reverse($out)) . "\n" . '</div> ';
    		else return '<div class="wp-pagenavi">' . "\n". implode("\n", array_reverse($out)) . "\n" . '</div> ';
    
    	} elseif ($page < 10) { //in the beginning
    		$ix=0;
    		while( 0 < $max_num_pages)
    		{ 	
    
    			if( (int) $page === (int) $max_num_pages )
    				$out[] = '<span class="current">' . $max_num_pages . '</span>';
    			else
    				 if ($max_num_pages <= 10) $out[] = str_replace('<a ', '<a class="page"', _wp_link_page($max_num_pages)) . $max_num_pages . '</a>';
    
    			$max_num_pages--; $ix++;
    		}
    	return '<div class="wp-pagenavi">' . "\n". implode("\n", array_reverse($out)) . " .. <a href='../$max_count/'>$max_count</a>\n" . '</div> ';
    	} else {  //in the middle
    
    		for ($max_num_pages = $page + 5; $max_num_pages>=$page - 5 ; $max_num_pages--) {
    
    		if( (int) $page === (int) $max_num_pages )
    			$out[] = '<span class="current">' . $max_num_pages . '</span>';
    		else
    			$out[] = str_replace('<a ', '<a class="page"', _wp_link_page($max_num_pages)) . $max_num_pages . '</a>';
    		}
    	return '<div class="wp-pagenavi">' . "\n<a href='../1/'>1</a> .. ". implode("\n", array_reverse($out)) . " .. <a href='../$max_count/'>$max_count</a>\n" . '</div> ';
    
    	}
    
    	}
    
    	return '';
    }

    In case you want to use it, it works only with url-rewriting enabled and it is for plugin version 1.6.5.4. It is located in /file-gallery/includes/templating.php at line 310.

    PS. I am a beginner in PHP and it is very late here, so code probably could be more optimised and you are welcome to do that ??
    PPS. Plugin developers, please include this (or similar) script in next plugin releases.

    Plugin Author Aesqe

    (@aesqe)

    Implemented in 1.6.7, it’ll be out by Monday.

    Thanks for the tip and the code, s0what! ??

    Plugin Author Aesqe

    (@aesqe)

    I’ve uploaded v1.7 to the trunk (development version), so please download it from here: https://downloads.www.ads-software.com/plugin/file-gallery.zip and see if everything works OK after upgrade.

    Please update like this:
    1) on the media settings page, make sure that the option “Delete all options on deactivation?” is NOT checked
    2) deactivate current version of the plugin
    3) delete current version of the plugin via WordPress interface, or just overwrite files on the server via FTP
    4) upload File Gallery 1.7 either via WordPress interface, or via FTP
    5) activate new version

    Thank you very much in advance, it helps me a lot when people test new versions before they are released to public ??

    Aesqe

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: File Gallery] What if there are 2000 gallery pages?’ is closed to new replies.