From 87eb90b4114122b8a043d515d144ff49d83d47e5 Mon Sep 17 00:00:00 2001 From: Tim Steiner <tsteiner2@unl.edu> Date: Tue, 29 Jun 2010 20:25:44 +0000 Subject: [PATCH] Support for setting an abbreviated site name in WDN Theme settings. git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x@114 20a16fea-79d4-4915-8869-1ea9d5ebf173 --- sites/all/themes/unl_wdn/template.php | 19 ++++++++++++++++--- sites/all/themes/unl_wdn/theme-settings.php | 7 +++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/sites/all/themes/unl_wdn/template.php b/sites/all/themes/unl_wdn/template.php index 5a0d4f75..fddf3caa 100644 --- a/sites/all/themes/unl_wdn/template.php +++ b/sites/all/themes/unl_wdn/template.php @@ -21,11 +21,11 @@ function unl_wdn_breadcrumb($variables) $breadcrumbs = $variables['breadcrumb']; if (count($breadcrumbs) == 0) { - $breadcrumbs[] = variable_get('site_name', 'Department'); + $breadcrumbs[] = unl_get_site_name_abbreviated(); } else { //Change 'Home' to be $site_name array_unshift($breadcrumbs, - str_replace('Home', variable_get('site_name', 'Department'), + str_replace('Home', unl_get_site_name_abbreviated(), array_shift($breadcrumbs))); } //Prepend UNL @@ -61,7 +61,7 @@ function unl_wdn_head_title() } // Change 'Home' to be $site_name - array_unshift($path, str_replace( 'Home', variable_get('site_name', 'Department'), array_shift($path))); + array_unshift($path, str_replace( 'Home', unl_get_site_name_abbreviated(), array_shift($path))); //Prepend UNL array_unshift($path, 'UNL'); @@ -165,3 +165,16 @@ EOF; return $output; } + +/** + * Return the abbreviated site name, assuming it has been set and we're not on the front page. + * Otherwise, it returns the full site name. + */ +function unl_get_site_name_abbreviated() +{ + if (!drupal_is_front_page() && theme_get_setting('site_name_abbreviation')) { + return theme_get_setting('site_name_abbreviation'); + } else { + return variable_get('site_name', 'Department'); + } +} diff --git a/sites/all/themes/unl_wdn/theme-settings.php b/sites/all/themes/unl_wdn/theme-settings.php index febbc4a3..af12d0c9 100644 --- a/sites/all/themes/unl_wdn/theme-settings.php +++ b/sites/all/themes/unl_wdn/theme-settings.php @@ -2,6 +2,13 @@ function unl_wdn_form_system_theme_settings_alter(&$form, &$form_state) { + $form['site_name_abbreviation'] = array( + '#type' => 'textfield', + '#title' => t('Site Name Abbreviation'), + '#default_value' => theme_get_setting('site_name_abbreviation'), + '#description' => t('An abbreviated version of your site\'s name to use in breadcrumbs.') + ); + $form['zen_forms'] = array( '#type' => 'checkbox', '#title' => t('Use Zen Forms'), -- GitLab