Hi,
I made a simple extension to add a css class to pagination links. Downside is a special hook needs to be added to the core.paginate.php file at the top of the show_links() method just after the global definitions for the method.
Add the following to core.paginate.php at line 79
// -------------------------------------------
// 'paginate_edit_object' hook.
// - Rewrite the show_links function in the core file and change variables
// ADDED BY HCCDevelopment 08/19/08 Brian Greenacre
//
if ($EXT->active_hook('paginate_edit_object') === TRUE)
{
$edata = $EXT->universal_call_extension('paginate_edit_object', $this);
if ($EXT->end_script === TRUE) return;
}
//
// -------------------------------------------
Here’s the extension code.
<?php
/*
================================================================
Pagination Plus Extension for ExpressionEngine
- by HCCDevelopment
----------------------------------------------------------------
File: ext.paginate_plus.php
Version: 0.1
Purpose: Add css class to pagination links
Compatibility: EE 1.6.x
Author: Brian Greenacre
----------------------------------------------------------------
Requiremens: Custom hook in core.paginate.php file in
method show_links() after the global definitions.
// -------------------------------------------
// 'paginate_edit_object' hook.
// - Rewrite the show_links function in the core file and change variables
// ADDED BY HCCDEVELOPMENT 08/19/08 Brian Greenacre
//
if ($EXT->active_hook('paginate_edit_object') === TRUE)
{
$edata = $EXT->universal_call_extension('paginate_edit_object', $this);
if ($EXT->end_script === TRUE) return;
}
//
// -------------------------------------------
================================================================
*/
class Paginate_plus
{
var $settings = array();
var $name = 'Paginate Plus';
var $version = '0.1';
var $description = 'Change the pagination functionality of show_links() and edit object variables.';
var $settings_exist = 'n';
var $docs_url = '';
function __construct($settings='')
{
$this->Paginate_plus($settings);
}
function Paginate_plus($settings='')
{
$this->settings = $settings;
}
function activate_extension()
{
global $DB;
$DB->query($DB->insert_string('exp_extensions',
array(
'extension_id' => '',
'class' => __CLASS__,
'method' => "paginate_edit",
'hook' => "paginate_edit_object",
'settings' => "",
'priority' => 10,
'version' => $this->version,
'enabled' => "y"
)
));
}
function disable_extension()
{
global $DB;
$DB->query("DELETE FROM exp_extensions WHERE class = '" . $DB->escape_str(__CLASS__) . "'");
}
// template parameter link_class='CSS-class'
function paginate_edit($paginate_obj)
{
global $TMPL, $EXT;
$EXT->end_script = FALSE;
$class = ( $TMPL->fetch_param('link_class') ) ? ' class="' . $TMPL->fetch_param('link_class') . '"' : '';
$paginate_obj->next_div_o .= '<span>';
$paginate_obj->next_div_c .= '</span>';
$paginate_obj->num_div_o .= '<span>';
$paginate_obj->num_div_c .= '</span>';
$paginate_obj->cur_div_o .= '<span>';
$paginate_obj->cur_div_c .= '</span>';
$paginate_obj->last_div_o .= '<span>';
$paginate_obj->last_div_c .= '</span>';
$paginate_obj->prev_div_o .= '<span>';
$paginate_obj->prev_div_c .= '</span>';
return true;
}
}
?>
As Brian was saying unfortunately the core.paginate.php needs to be hacked to add the hook, so if you upgrade or reinstall this would need to be redone every time. Maybe the powers to be could add this hook in the next build 😉
To use this extension add the link_class parameter to the weblog tag like so:
{exp:weblog:entries pagination="top" link_class="my_pagination_class"}
Then in your CSS you can define the class:
.my_pagination_class a { color: #000; border: solid 1px #333; etc…….}
Hope this helps.
Mike
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.