views_handler_field_node_path.inc

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

Handler for node path field.

File

modules/node/views_handler_field_node_path.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Handler for node path field.
  5. */
  6. /**
  7. * Field handler to present the path to the node.
  8. *
  9. * @ingroup views_field_handlers
  10. */
  11. class views_handler_field_node_path extends views_handler_field {
  12. function option_definition() {
  13. $options = parent::option_definition();
  14. $options['absolute'] = array('default' => FALSE, 'bool' => TRUE);
  15. return $options;
  16. }
  17. function construct() {
  18. parent::construct();
  19. $this->additional_fields['nid'] = 'nid';
  20. }
  21. function options_form(&$form, &$form_state) {
  22. parent::options_form($form, $form_state);
  23. $form['absolute'] = array(
  24. '#type' => 'checkbox',
  25. '#title' => t('Use absolute link (begins with "http://")'),
  26. '#default_value' => $this->options['absolute'],
  27. '#description' => t('Enable this option to output an absolute link. Required if you want to use the path as a link destination (as in "output this field as a link" above).'),
  28. '#fieldset' => 'alter',
  29. );
  30. }
  31. function query() {
  32. $this->ensure_my_table();
  33. $this->add_additional_fields();
  34. }
  35. function render($values) {
  36. $nid = $this->get_value($values, 'nid');
  37. return url("node/$nid", array('absolute' => $this->options['absolute']));
  38. }
  39. }