[wp-trac] [WordPress Trac] #3119: link_pages enhancement

WordPress Trac wp-trac at lists.automattic.com
Sat Sep 9 09:03:38 GMT 2006


#3119: link_pages enhancement
-------------------------+--------------------------------------------------
 Reporter:  _ck_         |       Owner:  anonymous
     Type:  enhancement  |      Status:  new      
 Priority:  low          |   Milestone:           
Component:  Template     |     Version:  2.1      
 Severity:  minor        |    Keywords:           
-------------------------+--------------------------------------------------
 A simple addition and shuffling of link_page code could allow an easy
 enhancement to allow BOTH kinds of numbers and "next page" links and also
 formatting for the current page, wrappers, bolding, etc.
  - some visitors need heavy-duty prompting clues...
 ie.
 ----
 << 1 2 '''[3]''' 4 5 >>
 ----
 {{{
 function link_pages($before='<br />', $after='<br />',
 $next_or_number='number', $nextpagelink='next page',
 $previouspagelink='previous page', $pagelink='%',
 $more_file='',$currentpage='%') {
         global $id, $page, $numpages, $multipage, $more, $pagenow;
         if ( $more_file != '' )
                 $file = $more_file;
         else
                 $file = $pagenow;
         if ( $multipage ) {
                 echo $before;
                 if ( 'next' || 'both' == $next_or_number ) {
                         if ( $more ) {

                                 $i = $page - 1;
                                 if ( $i && $more ) {
                                         if ( '' ==
 get_settings('permalink_structure') )
                                                 echo '<a href="' .
 get_permalink() . '&amp;page=' . $i . '">'.$previouspagelink.'</a>';
                                         else
                                                 echo '<a href="' .
 get_permalink() . $i . '/">'.$previouspagelink.'</a>';
                                 }
                         }
                 }
                 if ( 'number' || 'both' == $next_or_number ) {

                         for ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) {
                                 $j = str_replace('%',"$i",$pagelink);
                                 echo ' ';
                                 if ( ($i != $page) || ((!$more) &&
 ($page==1)) ) {
                                         if ( '' ==
 get_settings('permalink_structure') )
                                                 echo '<a href="' .
 get_permalink() . '&amp;page=' . $i . '">';
                                         else
                                                 echo '<a href="' .
 trailingslashit( get_permalink() ) . $i . '/">';
                                 }
                                 else {echo
 str_replace('%',"$i",$currentpage);}
                                 if ( ($i != $page) || ((!$more) &&
 ($page==1)) )
                                         echo $j.'</a>';
                         }

                 }
                 if ( 'next' || 'both' == $next_or_number ) {
                         if ( $more ) {

                                 $i = $page + 1;
                                 if ( $i <= $numpages && $more ) {
                                         if ( '' ==
 get_settings('permalink_structure') )
                                                 echo '<a
 href="'.get_permalink() . '&amp;page=' . $i . '">'.$nextpagelink.'</a>';
                                         else
                                                 echo '<a
 href="'.get_permalink().$i.'/">'.$nextpagelink.'</a>';
                                 }

                         }
                 }
         echo $after;
         }
 }
 }}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/3119>
WordPress Trac <http://wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list