/[drupal]/contributions/modules/comment_display/comment_display.module
ViewVC logotype

Contents of /contributions/modules/comment_display/comment_display.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Sun Nov 9 05:09:32 2008 UTC (12 months, 2 weeks ago) by sun
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +6 -1 lines
File MIME type: text/x-php
#329780 by jhedstrom, sun: Fixed Comment CSS/JS not added via preprocess_page.
1 <?php
2 // $Id: comment_display.module,v 1.1 2008/10/26 15:20:04 sun Exp $
3
4 /**
5 * @file
6 * Prevents rendering of comments inside of nodes and provides them as separate
7 * page elements instead.
8 */
9
10 /**
11 * Implementation of hook_menu_alter().
12 *
13 * Alters node.module's node view page callbacks to use ours instead.
14 */
15 function comment_display_menu_alter(&$callbacks) {
16 $callbacks['node/%node']['page callback'] = 'comment_display_node_page_view';
17 $callbacks['node/%node/revisions/%/view']['page callback'] = 'comment_display_node_show';
18 }
19
20 /**
21 * Generate a page displaying a single node, along with its comments.
22 *
23 * This is identically to node's implementation, but just does not append
24 * comments of the node.
25 */
26 function comment_display_node_show($node, $cid, $message = FALSE) {
27 if ($message) {
28 drupal_set_title(t('Revision of %title from %date', array('%title' => $node->title, '%date' => format_date($node->revision_timestamp))));
29 }
30 $output = node_view($node, FALSE, TRUE);
31
32 // Note: Output of comments moved into comment_display_preprocess_page().
33
34 // Update the history table, stating that this user viewed this node.
35 node_tag_new($node->nid);
36
37 return $output;
38 }
39
40 /**
41 * Menu callback; view a single node.
42 *
43 * Use our callback instead of node_show().
44 */
45 function comment_display_node_page_view($node, $cid = NULL) {
46 drupal_set_title(check_plain($node->title));
47 return comment_display_node_show($node, $cid);
48 }
49
50 /**
51 * Implementation of hook_preprocess_page().
52 *
53 * Provide node comments, if available, as $comments variable to theme.
54 */
55 function comment_display_preprocess_page(&$vars) {
56 $vars['comments'] = '';
57 if (function_exists('comment_render') && !empty($vars['node']) && $vars['node']->comment) {
58 $arg2 = arg(2);
59 $vars['comments'] .= comment_render($vars['node'], ($arg2 && is_numeric($arg2) ? $arg2 : NULL));
60
61 // Reconstruct CSS and JS variables.
62 $vars['css'] = drupal_add_css();
63 $vars['styles'] = drupal_get_css();
64 $vars['scripts'] = drupal_get_js();
65 }
66 }
67

  ViewVC Help
Powered by ViewVC 1.1.2