Fix for Post for g.d.o

  1. It's been a <em>long</em> time since I wrote this and I haven't revisited it to see if it could be made better with all I've learned since then.  So hopefully it's not too cringeworthy. :)
  2.  
  3. (in preprocess_comment)
  4. <?php
  5.   if (!isset($post_number)) {
  6.     static $post_number = 0;
  7.   }
  8.   _advanced_forum_topic_nid($variables['node']->nid);
  9.  
  10.   $post_per_page = _comment_get_display_setting('comments_per_page', $variables['node']);
  11.   $page_number = !empty($_GET['page']) ? $_GET['page'] : 0;
  12.   if (!$page_number) {
  13.     $page_number = 0;
  14.   }
  15.  
  16.   $post_number++;
  17.   $fragment = 'comment-' . $variables['comment']->cid;
  18.   $query = ($page_number) ? 'page=' . $page_number : NULL;
  19.   $linktext = '#' . (($page_number * $post_per_page) + $post_number);
  20.   $linkpath = 'node/' . _advanced_forum_topic_nid();
  21.   $variables['comment_link'] = l($linktext, $linkpath, array('query' => $query, 'fragment' => $fragment));;
  22. ?>
  23.  
  24. <?php
  25. /**
  26.  * Holds the node ID of the thread we are on.
  27.  *
  28.  * Used for linking the comment numbers.
  29.  *
  30.  * @param $nid
  31.  *   Node ID
  32.  */
  33. function _advanced_forum_topic_nid($node_id = 0) {
  34.   static $nid;
  35.  
  36.   if (!empty($node_id)) {
  37.     $nid = $node_id;
  38.   }
  39.  
  40.   return $nid;
  41. }
  42. ?>
  43.  
  44. Don't ask me why I have a function to hold the NID... I haven't the foggiest idea.
  45.  
  46. Michelle

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.