Skip to content

Instantly share code, notes, and snippets.

@mbabker
Created April 3, 2013 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbabker/5298041 to your computer and use it in GitHub Desktop.
Save mbabker/5298041 to your computer and use it in GitHub Desktop.
Joomla methods to render active and inactive pagination objects in the template
/**
* Renders an active item in the pagination block
*
* @param JPaginationObject $item The current pagination object
*
* @return string HTML markup for active item
*
* @since 3.0
*/
function pagination_item_active(&$item)
{
$class = '';
// Check for "Start" item
if ($item->text == JText::_('JLIB_HTML_START'))
{
$display = '<i class="icon-first"></i>';
}
// Check for "Prev" item
if ($item->text == JText::_('JPREV'))
{
$display = '<i class="icon-previous"></i>';
}
// Check for "Next" item
if ($item->text == JText::_('JNEXT'))
{
$display = '<i class="icon-next"></i>';
}
// Check for "End" item
if ($item->text == JText::_('JLIB_HTML_END'))
{
$display = '<i class="icon-last"></i>';
}
// If the display object isn't set already, just render the item with its text
if (!isset($display))
{
$display = $item->text;
$class = 'hidden-phone';
}
return "<li class=\"" . $class . "\"><a title=\"" . $item->text . "\" href=\"" . $item->link . "\" class=\"pagenav\">" . $display . "</a></li>";
}
/**
* Renders an inactive item in the pagination block
*
* @param JPaginationObject $item The current pagination object
*
* @return string HTML markup for inactive item
*
* @since 3.0
*/
function pagination_item_inactive(&$item)
{
// Check for "Start" item
if ($item->text == JText::_('JLIB_HTML_START'))
{
return '<li class="disabled"><a><i class="icon-first"></i></a></li>';
}
// Check for "Prev" item
if ($item->text == JText::_('JPREV'))
{
return '<li class="disabled"><a><i class="icon-previous"></i></a></li>';
}
// Check for "Next" item
if ($item->text == JText::_('JNEXT'))
{
return '<li class="disabled"><a><i class="icon-next"></i></a></li>';
}
// Check for "End" item
if ($item->text == JText::_('JLIB_HTML_END'))
{
return '<li class="disabled"><a><i class="icon-last"></i></a></li>';
}
// Check if the item is the active page
if (isset($item->active) && ($item->active))
{
return '<li class="active hidden-phone"><a>' . $item->text . '</a></li>';
}
// Doesn't match any other condition, render a normal item
return '<li class="disabled hidden-phone"><a>' . $item->text . '</a></li>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment