Commit 0fd53f58 authored by Danillo Brito's avatar Danillo Brito Committed by skwashd

Initial commit

parents
# Hide Vertical Tabs
Hide VTabs is a module to control visibility over the vertical tabs on a per
content type basis.
You have three options for setting the visibility:
- Hide vertical tabs
This will hide all the options that are selectable by the user that are under
vertical tabs group (additional_settings);
- Show vertical tabs
This is the Default option for vertical tabs, it will show all the tabs
normally;
- Show revision only
This option will remove the revision from the vertical tabs group
(additional_settings), and then hide the other items.
## Development
Hide VTabs is jointly developed by [CI&T](http://www.ciandt.com/) and [Dave Hall Consulting](http://davehall.com.au).
name = Hide Vertical Tabs
description = Controls the display of vertical tabs on a per content type basis
core = "7.x"
project = "hide_vtabs"
<?php
/**
* @file
* Hide Vertical Tabs module installation functions.
*/
/**
* Implements hook_install().
*/
function hide_vtabs_install() {
// To work properly, hide_vtabs must be the last module to load.
db_update('system')
->fields(array('weight' => '9999'))
->condition('name', 'hide_vtabs')
->execute();
}
<?php
/**
* @file
* Handle the display of vertical tabs on a per content type basis.
*/
define('HIDE_VTAB_STATUS_HIDDEN', 0);
define('HIDE_VTAB_STATUS_ENABLED', 1);
define('HIDE_VTAB_STATUS_REVISION_ONLY', 2);
/**
* Implement hook_form_BASE_FORM_ID_alter().
*/
function hide_vtabs_form_node_type_form_alter(&$form, &$form_state) {
$node_type = $form['#node_type']->type;
$options = array(
HIDE_VTAB_STATUS_ENABLED => 'Show vertical tabs',
HIDE_VTAB_STATUS_HIDDEN => 'Hide vertical tabs',
HIDE_VTAB_STATUS_REVISION_ONLY => 'Show revision only',
);
$form['hide_vtabs'] = array(
'#type' => 'fieldset',
'#title' => t('Hide Vertical Tabs'),
'#collapsible' => TRUE,
'#group' => 'additional_settings',
'#description' => t('Specify display settings of vertical tabs on current content type.'),
);
$form['hide_vtabs']['vtabs_status'] = array(
'#type' => 'radios',
'#default_value' => variable_get('hide_vtab_node_' . $node_type . '_status', HIDE_VTAB_STATUS_ENABLED),
'#options' => $options,
'#description' => t('Options available for vertical tabs visibility. "Show revision only" option will become a fieldset.'),
);
$form['#submit'][] = 'hide_vtabs_node_type_submit';
}
/**
* Submit handler to input the vertical tabs status.
*/
function hide_vtabs_node_type_submit(&$form, &$form_state) {
$node_type = $form['#node_type']->type;
variable_set('hide_vtab_node_' . $node_type . '_status', $form_state['values']['vtabs_status']);
}
/**
* Implements hook_form_BASE_FORM_ID_alter().
*/
function hide_vtabs_form_node_form_alter(&$form, &$form_state) {
$node_type = $form['type']['#value'];
$vtabs_status = variable_get('hide_vtab_node_' . $node_type . '_status', HIDE_VTAB_STATUS_ENABLED);
if (HIDE_VTAB_STATUS_ENABLED != $vtabs_status) {
if (HIDE_VTAB_STATUS_REVISION_ONLY == $vtabs_status) {
unset($form['revision_information']['#group']);
$form['revision_information']['#collapsible'] = FALSE;
}
unset($form['additional_settings']);
foreach ($form as $key => $value) {
if (is_array($form[$key]) && isset($form[$key]['#group'])) {
unset($form[$key]);
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment