Include first/last links by default, and dev version working better than official release

robhamm - June 3, 2009 - 16:02
Project:Custom Pagers
Version:6.x-1.10-beta1
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Since some of us use Custom Pagers for webcomics, would it be possible to include the first and last link code, even if it is commented out by default? (Also, can the changes in the dev version be rolled into the official release?)

Here is what I've done:
In custom_pagers.module I replaced

  $vars['previous'] = !empty($nav['prev']) ? l('‹ ' . t('previous'), 'node/'. $nav['prev']) : '';
  $vars['key'] = t('@count of @count_total', array('@count' => ($nav['current_index'] + 1), '@count_total' => count($nav['full_list'])));
  $vars['next'] =  !empty($nav['next']) ? l(t('next') . ' ›', 'node/'. $nav['next']) : '';

with

  $vars['first'] = ($nav['first']) ? l(t('‹‹ first'), 'node/'. $nav['first']) : '';
  $vars['previous'] = !empty($nav['prev']) ? l('‹ ' . t('previous'), 'node/'. $nav['prev']) : '';
  $vars['key'] = t('@count of @count_total', array('@count' => ($nav['current_index'] + 1), '@count_total' => count($nav['full_list'])));
  $vars['next'] =  !empty($nav['next']) ? l(t('next') . ' ›', 'node/'. $nav['next']) : '';
  $vars['last'] = ($nav['last']) ? l(t('latest ››'), 'node/'. $nav['last']) : '';

In custom_pager.tpl.php I replaced

<ul class="custom-pager custom-pager-<?php print $position; ?>">
<li class="previous"><?php print $previous; ?></li>
<li class="key"><?php print $key; ?></li>
<li class="next"><?php print $next; ?></li>
</ul>

with

<ul class="custom-pager custom-pager-<?php print $position; ?>">
<li class="first"><?php print $first; ?></li>
<li class="previous"><?php print $previous; ?></li>
<li class="key"><?php print $key; ?></li>
<li class="next"><?php print $next; ?></li>
<li class="last"><?php print $last; ?></li>
</ul>

Lastly, in custom_pagers.css, I'm using this CSS, which seems to pretty things up a bit when using first and last links:

ul.custom-pager {
  margin: 0;
  padding: 0;
  text-align: center;
}

ul.custom-pager li {
  margin: 0;
  padding-left: 10px;
  padding-right: 10px;
  display: inline;
  list-style-type: none;
  list-style-image: none;
  background: none;
  white-space: nowrap;
}

 
 

Drupal is a registered trademark of Dries Buytaert.