Commit eafba918 authored by Cody Craven's avatar Cody Craven
Browse files

Issue #1124168 by codycraven: Fixed fatal error on taxonomy term display page...

Issue #1124168 by codycraven: Fixed fatal error on taxonomy term display page configuration when Display Suite not installed and enabled.
parent b2c17ce9
......@@ -2,6 +2,8 @@
Taxonomy Display 7.x-1.x, YYYY-MM-DD
------------------------------------
Issue #1124168 by codycraven: Fixed fatal error on taxonomy term display page
configuration when Display Suite not installed and enabled.
Issue #1122992 by codycraven: Fixed fatal error on taxonomy term display page
configuration when no taxonomy display yet exists.
......
......@@ -23,6 +23,9 @@ function taxonomy_display_admin_form(&$form, &$form_state) {
return;
}
// Ensure 'additional_settings' exists.
taxonomy_display_admin_form_setup_additional_settings($form);
// Make things easy on users getting started with the module.
// We require the 'full' #view_mode to configure the taxonomy term page.
if ($form['#view_mode'] == 'default') {
......@@ -30,15 +33,14 @@ function taxonomy_display_admin_form(&$form, &$form_state) {
'#title' => 'Term page display',
'#type' => 'fieldset',
);
// TODO: There's got to be a better way to find out if 'full' is enabled,
// need to look.
foreach ($form['additional_settings']['modes']['view_modes_custom']['#default_value'] as $value) {
if ($value == 'full') {
$field['#description'] = 'To alter the term page display you need to go to the <em>Taxonomy term page</em> view mode.';
break;
}
// Find out if full mode is enabled and change the description for term page
// display to match.
$entity_info = entity_get_info('taxonomy_term');
$view_mode_settings = field_view_mode_settings('taxonomy_term', $form['#bundle']);
if ($view_mode_settings['full']['custom_settings']) {
$field['#description'] = 'To alter the term page display you need to go to the <em>Taxonomy term page</em> view mode.';
}
if (!isset($field['#description'])) {
else {
$field['#description'] = 'Enable the <em>Taxonomy term page</em> view mode under the <em>Custom display settings</em> tab to alter the term page display.';
}
$form['additional_settings']['taxonomy_display'] = $field;
......@@ -72,6 +74,38 @@ function taxonomy_display_admin_form(&$form, &$form_state) {
$form['#submit'][] = 'taxonomy_display_admin_form_submit';
}
/**
* Helper function; provide same form setup for compatibility as Display Suite.
*
* @param array $form
* The form array.
*
* @see http://drupal.org/node/1124168
* @see http://drupal.org/node/1124346
*/
function taxonomy_display_admin_form_setup_additional_settings(&$form) {
// If the additional_settings key does not exists (created by Display Suite)
// then reproduce what Display Suite does for compatibility.
if (!isset($form['additional_settings'])) {
$form['additional_settings'] = array(
'#type' => 'vertical_tabs',
'#theme_wrappers' => array('vertical_tabs'),
'#prefix' => '<div>',
'#suffix' => '</div>',
'#tree' => TRUE,
);
$form['#attached']['js'][] = 'misc/form.js';
$form['#attached']['js'][] = 'misc/collapse.js';
}
// If the modes field exists in the base form then move it in to the fieldset.
if (isset($form['modes'])) {
$form['additional_settings']['modes'] = $form['modes'];
$form['additional_settings']['modes']['#weight'] = -10;
unset($form['modes']);
}
}
/**
* Form submit callback; save Taxonomy Display settings for term pages.
*/
......
......@@ -87,3 +87,16 @@ function taxonomy_display_schema() {
* Implements hook_uninstall().
*/
function taxonomy_display_uninstall() {}
/**
* Implements hook_update_N().
*/
function taxonomy_display_update_7001() {
// Weight taxonomy display to run after display suite for manipulation of
// taxonomy display forms, see taxonomy_display_admin_form() and
// http://drupal.org/node/1124346
db_update('system')
->fields(array('weight' => 2))
->condition('name', 'taxonomy_display')
->execute();
}
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