3 * Handler for showing comment module's node link.
5 class views_handler_field_comment_node_link
extends views_handler_field
{
9 // Add the node fields that comment_link will need..
10 $this->additional_fields
['nid'] = array(
14 $this->additional_fields
['type'] = array(
18 $this->additional_fields
['comment'] = array(
24 function option_definition() {
25 $options = parent
::option_definition();
26 $options['teaser'] = array('default' => 0);
30 function options_form(&$form, &$form_state) {
31 parent
::options_form($form, $form_state);
33 $form['teaser'] = array(
34 '#type' => 'checkbox',
35 '#title' => t('Show teaser-style link'),
36 '#default_value' => $this->options
['teaser'],
37 '#description' => 'Show the comment link in the form used on standard node teasers, rather than the full node form.',
43 $this->ensure_my_table();
44 $this->add_additional_fields();
47 function render($values) {
49 $node = new
stdClass();
50 $node->nid
= $values->{$this->aliases
['nid']};
51 $node->type
= $values->{$this->aliases
['type']};
52 $node->comment
= $values->{$this->aliases
['comment']};
54 // Call comment.module's hook_link: comment_link($type, $node = NULL, $teaser = FALSE)
55 $links = comment_link('node', $node, $this->options
['teaser']);
56 // question: should we run these through: drupal_alter('link', $links, $node);
57 // might this have unexpected consequences if these hooks expect items in $node that we don't have?
59 return !empty($links) ?
theme('links', $links, array('class' => 'links inline')) : '';