Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function mymodule_form_alter(&$form, $form_state, $form_id) {
- if ($form_id == 'views_ui_edit_form')
- {
- $other = &$form['displays']['settings']['settings_content']['tab_content']['details']['columns']['third']['collapse']['other'];
- $other['custom']['#theme'] = 'views_ui_display_tab_setting';
- $other['custom']['#description'] = 'Custom';
- $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>';
- }
- }
- ['displays']['settings']['settings_content']['tab_content']['details']['columns']['third']['collapse']['other']
- /**
- * Implements hook_views_api().
- */
- function mymodule_views_api() {
- return array(
- 'api' => 3,
- 'path' => drupal_get_path('module', 'mymodule'),
- );
- }
- /**
- * Implements hook_views_plugins().
- */
- function mymodule_views_plugins() {
- $path = drupal_get_path('module', 'my_module');
- $plugins = array();
- $plugins['display_extender'] = array(
- 'mymodule' => array(
- 'title' => t('Some Setting'),
- 'help' => t('A description of the setting.'),
- 'path' => $path,
- 'handler' => 'mymodule_views_plugin_display_extender',
- ),
- );
- return $plugins;
- }
- class mymodule_views_plugin_display_extender extends views_plugin_display_extender {
- /**
- * Provide a form to edit options for this plugin.
- */
- function options_definition_alter(&$options) {
- $options['my_setting'] = array(
- 'default' => 0,
- );
- }
- /**
- * Provide a form to edit options for this plugin.
- */
- function options_form(&$form, &$form_state) {
- parent::options_form($form, $form_state);
- if ($form_state['section'] === 'mymodule') {
- $form['my_setting'] = array(
- '#type' => 'checkbox',
- '#title' => t('Some Setting'),
- '#description' => t('A sample checkbox.'),
- '#default_value' => $this->display->get_option('my_setting'),
- );
- }
- }
- /**
- * Handle any special handling on the validate form.
- */
- function options_submit(&$form, &$form_state) {
- $this->display->set_option('my_setting', $form_state['values']['my_setting']);
- }
- /**
- * Provide the default summary for options in the views UI.
- *
- * This output is returned as an array.
- */
- function options_summary(&$categories, &$options) {
- $options['mymodule'] = array(
- 'category' => 'other',
- 'title' => t('Some Setting'),
- 'value' => ($this->display->get_option('my_setting')) ? 'Yes' : 'No',
- 'desc' => t('Set a setting.'),
- );
- }
- }
- name = My Module
- description = Sample views display extender
- core = 7.x
- version = 7.x-1.0
- dependencies[] = views
- files[] = mymodule.views.inc
- files[] = mymodule_views_plugin_display_extender.inc
- $view->display_handler->get_option('my_setting');
- /**
- * Implements hook_views_post_execute().
- */
- function mymodule_views_post_execute(&$view) {
- $my_setting = $view->display_handler->get_option('my_setting');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement