Lack of hook for ‘First’ link, and a proposal for a more semantic (and precise?) approach to this plug-in
Posted: 31 January 2009 02:42 PM   Ignore ]  
Newbie
Rank
Total Posts:  4
Joined  2009-01-12

Now I’ve got this plugin working, with some adaptation, it comes very close to what I’ve been trying to achieve, namely proper semantic markup for EE pagination.

The only problem is a lack of control over the ‘First’ link!

I’ve outlined how I think pagination should be marked up on the EE forums.

Aside from semantics, the benefits to this markup approach are that one has all the hooks that are needed to individually style:

* First
* Previous
* Numbered page links
* Current (unlinked) page
* Next
* Last

With this approach in mind, I’ve changed your extension’s lines 86 to 95…

$paginate_obj->next_div_o    .= '<span' $class '>';
$paginate_obj->next_div_c    .= '</span>';
$paginate_obj->num_div_o    .= '<span' $class '>';
$paginate_obj->num_div_c    .= '</span>';
$paginate_obj->cur_div_o    .= '<span' $class '>';
$paginate_obj->cur_div_c    .= '</span>';
$paginate_obj->last_div_o    .= '<span' $class '>';
$paginate_obj->last_div_c    .= '</span>';
$paginate_obj->prev_div_o    .= '<span' $class '>';
$paginate_obj->prev_div_c    .= '</span>'

...to…

$paginate_obj->next_div_o    .= '<li class="next">';
$paginate_obj->next_div_c    .= '</li>';
$paginate_obj->num_div_o    .= '<li>';
$paginate_obj->num_div_c    .= '</li>';
$paginate_obj->cur_div_o    .= '<li>';
$paginate_obj->cur_div_c    .= '</li>';
$paginate_obj->last_div_o    .= '<li class="last">';
$paginate_obj->last_div_c    .= '</li>';
$paginate_obj->prev_div_o    .= '<li class="previous">';
$paginate_obj->prev_div_c    .= '</li>'

But as is self evident in the above code extracts, there’s no control over what wraps the First link.

Sorting this out is beyond the wit of my limited PHP skills! Can I ask you guys to add it in please?

And what do you think about the pagination markup approach?

Profile
 
Posted: 31 January 2009 03:14 PM   Ignore ]   [ # 1 ]  
Newbie
Rank
Total Posts:  4
Joined  2009-01-12

Hmmm…

Just realised rather belatedly that I can achieve exactly what I’m after by hacking core.paginate.php (1.6.6) as attached. Changes made to…

Lines 42 to 45:

var $next_link        'Next';
var 
$prev_link        'Previous';
var 
$first_marker    '';
var 
$last_marker    ''

Lines 134 to 140 (removed all those nasty no breaking spaces!):

if ($this->next_div_o == '')    $this->next_div_o '';
if (
$this->num_div_o == '')        $this->num_div_o '';
if (
$this->cur_div_o == '')        $this->cur_div_o '';
if (
$this->last_div_o == '')    $this->last_div_o '';
if (
$this->prev_div_o == '')    $this->prev_div_o '';
if (
$this->prev_div_c == '')    $this->prev_div_c ''.$this->prev_div_c ;
if (
$this->first_div_c == '')    $this->first_div_c ''.$this->first_div_c 

Line 170:

$output .= $this->first_div_o.'<li class="first"><a >suffix.'">'.$this->first_page.'</a></li>'.$this->first_div_c; 

Line 183:

$output .= $this->prev_div_o.'<li class="previous"><a >prefix.$i.$slash.$this->suffix.'">'.$this->prev_link.'</a></li>'.$this->prev_div_c; 

Lines 201 and 205:

{
  $output 
.= $this->cur_div_o.'<li><strong>'.$loop.'</strong></li>'.$this->cur_div_c// Current page
}
else
{
  $output 
.= $this->num_div_o.'<li><a >prefix.$i.$slash.$this->suffix.'">'.$loop.'</a></li>'.$this->num_div_c;

Line 216:

$output .= $this->next_div_o.'<li class="next"><a >prefix.($this->cur_page * $this->per_page).$slash.$this->suffix.'">'.$this->next_link.'</a></li>'.$this->next_div_c; 

Line 227:

$output .= $this->last_div_o.'<li class="last"><a >prefix.$i.$slash.$this->suffix.'">'.$this->last_page.'</a></li>'.$this->last_div_c; 

—-

I’d love to see this rolled into a plugin instead though.

Over to you guys?!

File Attachments 
core.paginate.php.zip  (File Size: 3KB - Downloads: 477)
Profile
 
Posted: 31 January 2009 08:28 PM   Ignore ]   [ # 2 ]  
Administrator
Avatar
RankRankRankRank
Total Posts:  1654
Joined  2007-11-23

Your timing is very scary. I was just working on this last night and would like to enhance the pagination extension as well. Your right though the only way to do it is to hack the core file more, I like what you did. Keep it up!

Signature 

Mike

HCC Development

Profile
 
Posted: 17 July 2009 03:48 PM   Ignore ]   [ # 3 ]  
Newbie
Rank
Total Posts:  5
Joined  2009-05-07

It appears that the bug is still in the existing pagination style extension. It’s an easy fix if you don’t want to make sweeping changes to your pagination approach which might be on a production server and can’t go through a lot of down time.

To fix the existing extension so that the ‘first’ link also gets styled… simply look for this code in the extension beginning around line 86.

$paginate_obj->next_div_o    .= '<span' $class '>';
        
$paginate_obj->next_div_c    .= '</span>';
        
$paginate_obj->num_div_o    .= '<span' $class '>';
        
$paginate_obj->num_div_c    .= '</span>';
        
$paginate_obj->cur_div_o    .= '<span' $class '>';
        
$paginate_obj->cur_div_c    .= '</span>';
        
$paginate_obj->last_div_o    .= '<span' $class '>';
        
$paginate_obj->last_div_c    .= '</span>';
        
$paginate_obj->prev_div_o    .= '<span' $class '>';
        
$paginate_obj->prev_div_c    .= '</span>'

and add the first_div flag like this…

$paginate_obj->next_div_o    .= '<span' $class '>';
        
$paginate_obj->next_div_c    .= '</span>';
        
$paginate_obj->num_div_o    .= '<span' $class '>';
        
$paginate_obj->num_div_c    .= '</span>';
        
$paginate_obj->cur_div_o    .= '<span' $class '>';
        
$paginate_obj->cur_div_c    .= '</span>';
        
$paginate_obj->first_div_o    .= '<span' $class '>';
        
$paginate_obj->first_div_c    .= '</span>';
        
$paginate_obj->last_div_o    .= '<span' $class '>';
        
$paginate_obj->last_div_c    .= '</span>';
        
$paginate_obj->prev_div_o    .= '<span' $class '>';
        
$paginate_obj->prev_div_c    .= '</span>'

That should take care of it without any other changes.

Profile
 
   
 
 

Join our Mailing List