views_handler_field_node_link.inc

  1. 3.x modules/node/views_handler_field_node_link.inc
  2. 2.x modules/node/views_handler_field_node_link.inc

File

modules/node/views_handler_field_node_link.inc
View source
  1. <?php
  2. /**
  3. * Field handler to present a link to the node.
  4. */
  5. class views_handler_field_node_link extends views_handler_field {
  6. function construct() {
  7. parent::construct();
  8. $this->additional_fields['nid'] = 'nid';
  9. }
  10. function option_definition() {
  11. $options = parent::option_definition();
  12. $options['text'] = array('default' => '', 'translatable' => TRUE);
  13. return $options;
  14. }
  15. function options_form(&$form, &$form_state) {
  16. parent::options_form($form, $form_state);
  17. $form['text'] = array(
  18. '#type' => 'textfield',
  19. '#title' => t('Text to display'),
  20. '#default_value' => $this->options['text'],
  21. );
  22. }
  23. function query() {
  24. $this->ensure_my_table();
  25. $this->add_additional_fields();
  26. }
  27. function render($values) {
  28. $text = !empty($this->options['text']) ? $this->options['text'] : t('view');
  29. $nid = $values->{$this->aliases['nid']};
  30. return l($text, "node/$nid");
  31. }
  32. }