Experimental project
This is a sandbox project, which contains experimental code for developer use only.
How many times have you been forced to use Views because it provides XYZ and writing that by hand would be painful? This module aims to ease some of that pain.
What this module is not:
- A replacement for Views
- A fancy interface for site builders
- A module that provides free beer (still working on this one)
What this module does do:
- Allows you to make your pager links AJAXified without writing a ton of code
This is especially useful if you are using an alternate data backend (we're looking at you MongoDB) and you can't use Views. For anyone who has used Views before with MongoDB, you know what we mean. For those of you that haven't, let's just say that the integration isn't as nice as it could be. Here's an example of code that we use to generate the equivalent of a "View":
function _ajax_pagination_page_callback_example() {
$query = new EntityFieldQuery();
$query->entityCondition("entity_type", "node")
->pager();
$results = $query->execute();
$output = '';
if (!empty($results['node'])) {
foreach ($results['node'] as $nid => $node) {
$output .= drupal_render(node_load($nid), 'teaser');
}
}
return $output . theme('ajax_pager', array('parameters' => array('selector' => 'block-system-main')));
}
The Nitty Gritty Details
- Create a query that you want to paginate. You can use EntityFieldQuery, dbQuery, etc
- Instead of using "theme('pager');" to generate your pager, use "theme('ajax_pager')" and pass the ID of the container as the second part of the parameters.
- Watch as your paginated display starts using AJAX.
Project information
- Project categories: Content display, Developer tools
- Created by rvtraveller on , updated
