Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function my_em_paginate($links, $link, $total, $limit, $page=1, $pagesToShow=10)
- {
- if ($limit > 0)
- {
- $url_parts = explode('?', $link);
- $base_link = $url_parts[0];
- //Get querystring for first page without page
- $query_arr = array();
- parse_str($url_parts[1], $query_arr);
- unset($query_arr['page']); unset($query_arr['pno']);
- $base_querystring = build_query($query_arr);
- if( !empty($base_querystring) ) $base_querystring = '?'.$base_querystring;
- //calculate
- $maxPages = ceil($total/$limit); //Total number of pages
- $placeholder = urlencode('%PAGE%');
- $link = str_replace('%PAGE%', $placeholder, $link); //To avoid url encoded/non encoded placeholders
- $string = '<div id="paginator"><div id="paginator_left"></div>';
- $string .= '<div id="paginator_mid">';
- $string .= '<span id="prev">';
- if ($page > 1)
- {
- $string .= '<a href="'.str_replace($placeholder,$page-1,$link).'" title="Previous"> </a>';
- }
- $string .= '</span>';
- $string .= '<span id="next">';
- if ($page < $maxPages)
- {
- $string .= '<a href="'.str_replace($placeholder,$page+1,$link).'" title="Next"> </a>';
- }
- $string .= '</span>';
- $string .= '</div>';
- $string .= '<div id="paginator_right"></div></div>';
- //Return the string
- return apply_filters('em_paginate', $string);
- }
- }
- add_filter('em_events_output_pagination','my_em_paginate', 1, 6);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement