views_handler_field_custom.inc

  1. 3.x handlers/views_handler_field_custom.inc
  2. 2.x handlers/views_handler_field_custom.inc

File

handlers/views_handler_field_custom.inc
View source
  1. <?php
  2. /**
  3. * A handler to provide a field that is completely custom by the administrator.
  4. *
  5. * @ingroup views_field_handlers
  6. */
  7. class views_handler_field_custom extends views_handler_field {
  8. function query() {
  9. // do nothing -- to override the parent query.
  10. }
  11. function option_definition() {
  12. $options = parent::option_definition();
  13. // Override the alter text option to always alter the text.
  14. $options['alter']['contains']['alter_text'] = array('default' => TRUE);
  15. $options['hide_alter_empty'] = array('default' => FALSE);
  16. return $options;
  17. }
  18. function options_form(&$form, &$form_state) {
  19. parent::options_form($form, $form_state);
  20. // Remove the checkbox
  21. unset($form['alter']['alter_text']);
  22. unset($form['alter']['text']['#dependency']);
  23. unset($form['alter']['text']['#process']);
  24. }
  25. function render($values) {
  26. // Return the text, so the code never thinks the value is empty.
  27. return $this->options['alter']['text'];
  28. }
  29. }