views_load_more.module in Views Load More 6
Same filename and directory in other branches
Provides a replacement pager element for Views displays.
File
views_load_more.moduleView source
<?php
/**
* @file
* Provides a replacement pager element for Views displays.
*/
/**
* Implementation of hook_views_api().
*
* @see hook_views_api()
*/
function views_load_more_views_api() {
return array(
'api' => '3.0-alpha1',
);
}
// We need to implement our own tpls for items being return via the load-more pager.
/**
* Implementation of hook_theme().
*
* @see hook_theme()
*/
function views_load_more_theme() {
return array(
'views_load_more_pager' => array(
'arguments' => array(
'element' => 0,
),
),
);
}
/**
* Implementation of hook_ajax_data_alter().
*
* @param $object
* The settings to be modified.
* @param $type
* The object type (usually just 'view').
* @param $view
* The View which will be manipulated.
*
* @see hook_ajax_data_alter()
*/
function views_load_more_ajax_data_alter(&$object, $type, $view) {
// Change the callback if its a views_load_more pagers.
if (is_a($view->query->pager, 'views_plugin_pager_load_more')) {
// If AJAX driven exposed filters are enabled, and the exposed form
// is submitted, we'll return to page 0. Skip our callback on the
// very first page.
if ($view->query->pager->current_page <= 0) {
return;
}
$object->__callbacks = array(
'Drupal.viewsLoadMore',
);
}
}
/**
* Provides a theme implementation for the pager element.
* @param $text
* The anchor text that will be used for this pager link.
* @param $limit
* How many items should be paged.
* @param $element
* (Not sure how this is used)
* @param $parameters
* GET parameters passed to theme_pager_next().
* @param $quantity
* The number of "pages" to display. Ignored by this module.
* @return
* A themed pager element.
* @retval string
*/
function theme_views_load_more_pager($text = '', $limit = 10, $element = 0, $parameters = array(), $quantity = 9) {
global $pager_total;
// Lets add our JS.
drupal_add_js(drupal_get_path('module', 'views_load_more') . '/views_load_more.js', 'module');
// Lets get out load more button.
$li_next = theme('pager_next', !empty($text) ? t($text) : t('Load More'), $limit, $element, 1, $parameters);
if (empty($li_next)) {
$li_next = " ";
}
if ($pager_total[$element] > 1) {
$items[] = array(
'class' => 'pager-next',
'data' => $li_next,
);
return theme('item_list', $items, NULL, 'ul', array(
'class' => 'pager',
));
}
}
Functions
Name | Description |
---|---|
theme_views_load_more_pager | Provides a theme implementation for the pager element. |
views_load_more_ajax_data_alter | Implementation of hook_ajax_data_alter(). |
views_load_more_theme | Implementation of hook_theme(). |
views_load_more_views_api | Implementation of hook_views_api(). |