Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. function mymodule_form_alter(&$form, $form_state, $form_id) {
  2. if ($form_id == 'views_ui_edit_form')
  3. {
  4. $other = &$form['displays']['settings']['settings_content']['tab_content']['details']['columns']['third']['collapse']['other'];
  5. $other['custom']['#theme'] = 'views_ui_display_tab_setting';
  6. $other['custom']['#description'] = 'Custom';
  7. $other['custom']['#link'] = '<a href="' . base_path() . '/node/1" title="Get information on how to theme this display" id="views-page-1-custom">Custom</a>';
  8.  
  9. }
  10.  
  11. }
  12.  
  13. ['displays']['settings']['settings_content']['tab_content']['details']['columns']['third']['collapse']['other']
  14.  
  15. /**
  16. * Implements hook_views_api().
  17. */
  18. function mymodule_views_api() {
  19. return array(
  20. 'api' => 3,
  21. 'path' => drupal_get_path('module', 'mymodule'),
  22. );
  23. }
  24.  
  25. /**
  26. * Implements hook_views_plugins().
  27. */
  28. function mymodule_views_plugins() {
  29. $path = drupal_get_path('module', 'my_module');
  30. $plugins = array();
  31.  
  32. $plugins['display_extender'] = array(
  33. 'mymodule' => array(
  34. 'title' => t('Some Setting'),
  35. 'help' => t('A description of the setting.'),
  36. 'path' => $path,
  37. 'handler' => 'mymodule_views_plugin_display_extender',
  38. ),
  39. );
  40.  
  41. return $plugins;
  42. }
  43.  
  44. class mymodule_views_plugin_display_extender extends views_plugin_display_extender {
  45. /**
  46. * Provide a form to edit options for this plugin.
  47. */
  48. function options_definition_alter(&$options) {
  49. $options['my_setting'] = array(
  50. 'default' => 0,
  51. );
  52. }
  53.  
  54. /**
  55. * Provide a form to edit options for this plugin.
  56. */
  57. function options_form(&$form, &$form_state) {
  58. parent::options_form($form, $form_state);
  59.  
  60. if ($form_state['section'] === 'mymodule') {
  61. $form['my_setting'] = array(
  62. '#type' => 'checkbox',
  63. '#title' => t('Some Setting'),
  64. '#description' => t('A sample checkbox.'),
  65. '#default_value' => $this->display->get_option('my_setting'),
  66. );
  67. }
  68. }
  69.  
  70. /**
  71. * Handle any special handling on the validate form.
  72. */
  73. function options_submit(&$form, &$form_state) {
  74. $this->display->set_option('my_setting', $form_state['values']['my_setting']);
  75. }
  76.  
  77. /**
  78. * Provide the default summary for options in the views UI.
  79. *
  80. * This output is returned as an array.
  81. */
  82. function options_summary(&$categories, &$options) {
  83. $options['mymodule'] = array(
  84. 'category' => 'other',
  85. 'title' => t('Some Setting'),
  86. 'value' => ($this->display->get_option('my_setting')) ? 'Yes' : 'No',
  87. 'desc' => t('Set a setting.'),
  88. );
  89. }
  90.  
  91. }
  92.  
  93. name = My Module
  94. description = Sample views display extender
  95. core = 7.x
  96. version = 7.x-1.0
  97.  
  98. dependencies[] = views
  99.  
  100. files[] = mymodule.views.inc
  101. files[] = mymodule_views_plugin_display_extender.inc
  102.  
  103. $view->display_handler->get_option('my_setting');
  104.  
  105. /**
  106. * Implements hook_views_post_execute().
  107. */
  108. function mymodule_views_post_execute(&$view) {
  109. $my_setting = $view->display_handler->get_option('my_setting');
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement