Categories
drupal

Drupal Custom pager and Display suite

When enabling a Display Suite layout, your custom pagers will disappear.
This can easily be resolved using a node display custom field.
The custom field feature is great and allows for very powerful stuff and it lets you get around most issues.

I’ll provide the solution first and explain later as this can be used to bring in content from other custom modules that add content to the node.

The solution

Get the pager details:
1. Go to Home › Site building › Custom pagers (admin/build/custom_pagers)
2. Edit the custom pager and make note of the ID its in the URL admin/build/custom_pagers/edit/1 (pager id = 1)
3. set the pager position to Above the Node body (you will be able to position it using Display Suite wherever you want)
4. Hit the submit to save changes

Add the Node display field
1) Go to Home › Site building › Display suite › Node displays (admin/build/ds/nd/fields )
2) Expend the “Add new code field”
3) Giver it a key and title. Make those specific to the pager so something like custom_gallery_pager and custom gallery pager
4) Set the content type the field is relevant to in the “Field exclude” section. you must check all types except the one you are interested in (reverse logic)
5) And finely add the “Field code”
content['custom_pager_top'][1]["#value"]; ?>
Replace [1] with the relevant pager id you (Get the pager details stage 2) and Save

You an now use your field in your DS layout (:

Analysis

Modules that add content to a node would usually add it in the nodeapi to the node content so the first place to look is the node api of the module.
Below is an extract

function custom_pagers_nodeapi(&$node, $op, $teaser, $page) {
switch ($op) {
case 'view':
// We want to make sure we don't try to output when print.module is active.
// It's a bit of special casing but it doesn't do much harm.
if ($teaser == FALSE && empty($node->printing)) {
......................
switch ($pager->position) {
case 'top':
$node->content['custom_pager_top'][$pager->pid] = array('#value' => theme('custom_pager', $nav_array, $node, $pager, 'top'));
break;
case 'bottom':

its easy to see how the code adds the content. It does this by creating a new array element according to the $pager->position.
In the case of ‘top’ this is:
$node->content['custom_pager_top'][$pager->pid] = array('#value' => theme('custom_pager', $nav_array, $node, $pager, 'top'));
so the ‘#value’ will hold the actual pager giving us (for pager id 1):
$node->content['custom_pager_top'][1]["#value"]
when using node display fields you must replace the $node variable with $object so the filed code is
content['custom_pager_top'][1]["#value"]; ?>

Categories
CMS drupal Technology

Some usfull drupal links

http://drupal.org/ The main drupal site

http://groups.drupal.org/ Is part of the drupal.org group of sites. groups.drupal.org serves the Drupal community by providing a place for groups to organize

http://drupal.org/project/gmap Drupals gmap Module. The GMap module provides an interface to the Google Maps API within Drupal.

http://www.chicagoancestors.org/ an example of using Drupal.gmap

http://drupal.org/project/ubercart Ubercart Ubercart is an e-commerce suite developed for Drupal.

http://livetest.ubercart.org/uc1/ Ubercart 1.x livetest: showcasing droople Ubercart