G2A Many GEOs
SHARE
TWEET

http://www.pjmccormick.com/next-previous-node-links-drupal-7

Juc1 Apr 25th, 2014 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. o1@jupiter:~/static/jupiter-070314/sites/test-270414.click-monkey.net$ drush dl prev_next
  2. Project prev_next (7.x-1.x-dev) downloaded to /data/disk/o1/static/jupiter-070314/sites/all/modules/prev_next.      [success]
  3. Project prev_next contains 2 modules: prev_next_views, prev_next.
  4. o1@jupiter:~/static/jupiter-070314/sites/test-270414.click-monkey.net$ drush en prev_next
  5. The following extensions will be enabled: prev_next
  6. Do you really want to continue? (y/n): y
  7. prev_next was enabled successfully.                                  [ok]
  8. Prev/Next will index from node 50 downward.                          [status]
  9. o1@jupiter:~/static/jupiter-070314/sites/test-270414.click-monkey.net$ cd ../themes/garland
  10. o1@jupiter:~/static/jupiter-070314/themes/garland$ cat template.php
  11. <?php
  12. function pn_node($node, $mode = 'n') {
  13.   if (!function_exists('prev_next_nid')) {
  14.     return NULL;
  15.   }
  16.  
  17.   switch($mode) {
  18.     case 'p':
  19.       $n_nid = prev_next_nid($node->nid, 'prev');
  20.         $link_text = 'previous';
  21.       break;
  22.  
  23.     case 'n':
  24.       $n_nid = prev_next_nid($node->nid, 'next');
  25.       $link_text = 'next';
  26.     break;
  27.  
  28.     default:
  29.     return NULL;
  30.   }
  31.  
  32.   if ($n_nid) {
  33.     $n_node = node_load($n_nid);
  34.  
  35.     switch($n_node->type) {
  36.       case 'article':
  37.         $html = l('"'.$n_node->title .'"', 'node/'.$n_node->nid);
  38.       return $html;
  39.     }
  40.   }
  41. }
  42. o1@jupiter:~/static/jupiter-070314/themes/garland$ cat node.tpl.php
  43. <?php
  44. ?>
  45. <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
  46.  
  47.   <?php print $user_picture; ?>
  48.  
  49.   <?php print render($title_prefix); ?>
  50.   <?php if (!$page): ?>
  51.     <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
  52.   <?php endif; ?>
  53.   <?php print render($title_suffix); ?>
  54.  
  55.   <?php if ($display_submitted): ?>
  56.     <span class="submitted"><?php print $submitted ?></span>
  57.   <?php endif; ?>
  58.  
  59.   <div class="content clearfix"<?php print $content_attributes; ?>>
  60.     <?php
  61.       // We hide the comments and links now so that we can render them later.
  62.       hide($content['comments']);
  63.       hide($content['links']);
  64.       print render($content);
  65.     ?>
  66.   </div>
  67.  
  68.   <div class="clearfix">
  69.     <?php if (!empty($content['links'])): ?>
  70.       <div class="links"><?php print render($content['links']); ?></div>
  71.     <?php endif; ?>
  72.  
  73.     <?php print render($content['comments']); ?>
  74.   </div>
  75.  
  76. <?php
  77. Print "Hello, World! yes";
  78. ?>
  79.  
  80. <ul>
  81.   <li><?php print pn_node($node, 'n'); ?></li>
  82.   <li><?php print pn_node($node, 'p'); ?></li>
  83. </ul>
  84. </div>
  85. o1@jupiter:~/static/jupiter-070314/themes/garland$
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top