diff --git a/sites/all/modules/unl/unl.module b/sites/all/modules/unl/unl.module index c28a594ce448249def444a8e25995436ded23018..a72a27ae9b00ab42e1da97be69845fdec640b2ae 100644 --- a/sites/all/modules/unl/unl.module +++ b/sites/all/modules/unl/unl.module @@ -195,6 +195,7 @@ function unl_wysiwyg_plugin($editor) { 'buttons' => array( 'unlZenBox' => 'UNL Zen Box', 'unlZenTable' => 'UNL Zen Table', + 'unlGrid' => 'UNL Grid', 'unlLayout' => 'UNL Layout', 'unlTooltip' => 'UNL Tooltip', ), diff --git a/sites/all/themes/unl_wdn/page.tpl.php b/sites/all/themes/unl_wdn/page.tpl.php index 03b9f712fbeeea2badfb870b1d5519c85988e54f..0af9e8ef22a7ddd79493383d9a58df97ab556217 100644 --- a/sites/all/themes/unl_wdn/page.tpl.php +++ b/sites/all/themes/unl_wdn/page.tpl.php @@ -98,34 +98,13 @@ else { } if ($page['sidebar_first']) { - $t->maincontentarea .= '<div id="sidebar-first" class="sidebar col left">' . PHP_EOL - . render($page['sidebar_first']) . PHP_EOL - . '</div>'; + $t->maincontentarea .= render($page['sidebar_first']) . PHP_EOL; } - -if ($page['sidebar_first'] && !$page['sidebar_second']) { - $t->maincontentarea .= '<div class="three_col right">' . PHP_EOL; -} -else if ($page['sidebar_first'] && $page['sidebar_second']) { - $t->maincontentarea .= '<div class="two_col">' . PHP_EOL; -} -else if (!$page['sidebar_first'] && $page['sidebar_second']) { - $t->maincontentarea .= '<div class="three_col left">' . PHP_EOL; -} - $t->maincontentarea .= strtr(render($page['content']), array('sticky-enabled' => 'zentable cool')) . PHP_EOL; - if ($page['sidebar_second']) { - $t->maincontentarea .= '</div>' . PHP_EOL - . '<div id="sidebar-second" class="sidebar col right">' . PHP_EOL - . render($page['sidebar_second']) . PHP_EOL - . '</div>' . PHP_EOL; + $t->maincontentarea .= render($page['sidebar_second']) . PHP_EOL; } -if ($page['sidebar_first'] && !$page['sidebar_second']) { - $t->maincontentarea .= '</div>' . PHP_EOL; -} - // Related Links if ($page['leftcollinks']) { $t->leftcollinks = render($page['leftcollinks']); diff --git a/sites/all/themes/unl_wdn/region.tpl.php b/sites/all/themes/unl_wdn/region.tpl.php index 2e904294827510a009ebfeed9556de6e1fe6390a..c17f140d74e47e6cb09f7da3cb49ed2f8edb212f 100644 --- a/sites/all/themes/unl_wdn/region.tpl.php +++ b/sites/all/themes/unl_wdn/region.tpl.php @@ -1,9 +1,8 @@ <?php -// $Id: region.tpl.php,v 1.1 2009/10/05 02:43:01 webchick Exp $ /** * @file - * Default theme implementation to display a region. + * unl_wdn theme implementation to display a region. * * Available variables: * - $content: The content for this region, typically blocks. @@ -14,6 +13,7 @@ * - region-[name]: The name of the region with underscores replaced with * dashes. For example, the page_top region would have a region-page-top class. * - $region: The name of the region variable as defined in the theme's .info file. + * - $region_name: The name of the region variable with '_' replaced with '-'. * * Helper variables: * - $classes_array: Array of html class attribute values. It is flattened @@ -26,5 +26,12 @@ * @see template_preprocess_region() * @see template_process() */ +?> -echo $content; +<?php if ($region != 'navlinks'): ?> +<div id="<?php print $region_name; ?>" class="<?php print $classes; ?>"> +<?php endif;?> + <?php print $content; ?> +<?php if ($region != 'navlinks'): ?> +</div> +<?php endif;?> \ No newline at end of file diff --git a/sites/all/themes/unl_wdn/template.php b/sites/all/themes/unl_wdn/template.php index 615a3cfd8e51ea0f944807fe3700ce90aff6bf1e..4a2ffd8e0b75538ee470bf2e17e2f79bb9c4941e 100644 --- a/sites/all/themes/unl_wdn/template.php +++ b/sites/all/themes/unl_wdn/template.php @@ -58,6 +58,41 @@ function unl_wdn_preprocess_html(&$vars, $hook) { $vars['head_title'] = check_plain(implode(' | ', $head_title)); } +/** + * Implements template_preprocess_region(). + * Adds grid classes for sidebar_first, sidebar_second, and content regions. + */ +function unl_wdn_preprocess_region(&$vars) { + static $grid; + if (!isset($grid)) { + $grid = _unl_wdn_grid_info(); + } + + $vars['region_name'] = str_replace('_', '-', $vars['region']); + $vars['classes_array'][] = $vars['region_name']; + + if (in_array($vars['region'], array_keys($grid['regions']))) { + $vars['classes_array'][] = 'grid' . $grid['regions'][$vars['region']]['width']; + } + + // Sidebar regions receive common 'sidebar' class + $sidebar_regions = array('sidebar_first', 'sidebar_second'); + if (in_array($vars['region'], $sidebar_regions)) { + $vars['classes_array'][] = 'sidebar'; + } + + // Determine which region needs the 'first' class + if ($vars['region'] == 'content' && $grid['regions']['sidebar_first']['width'] == 0) { + $vars['classes_array'][] = 'first'; + } + else if ($vars['region'] == 'sidebar_first') { + $vars['classes_array'][] = 'first'; + } +} + +/** + * Implements template_preprocess_node(). + */ function unl_wdn_preprocess_node(&$vars) { // Drupal doesn't correctly set the $page flag for the preview on node/add/page which results in the <h2> being displayed in modules/node/node.tpl.php if (isset($vars['elements']['#node']->op) && $vars['elements']['#node']->op == 'Preview') { @@ -261,3 +296,30 @@ function unl_wdn_get_site_name_abbreviated() { return variable_get('site_name', 'Department'); } } + +/** + * Generate grid numbers for sidebar_first, sidebar_second, and content regions. + * Based on work in the Fusion theme (fusion_core_grid_info()). + */ +function _unl_wdn_grid_info() { + static $grid; + if (!isset($grid)) { + $grid = array(); + $grid['width'] = 12; + $sidebar_first_width = (block_list('sidebar_first')) ? theme_get_setting('sidebar_first_width') : 0; + $sidebar_second_width = (block_list('sidebar_second')) ? theme_get_setting('sidebar_second_width') : 0; + $grid['regions'] = array(); + + $regions = array('sidebar_first', 'sidebar_second', 'content'); + foreach ($regions as $region) { + if ($region == 'content') { + $region_width = $grid['width'] - $sidebar_first_width - $sidebar_second_width; + } + if ($region == 'sidebar_first' || $region == 'sidebar_second') { + $region_width = ($region == 'sidebar_first') ? $sidebar_first_width : $sidebar_second_width; + } + $grid['regions'][$region] = array('width' => $region_width); + } + } + return $grid; +} diff --git a/sites/all/themes/unl_wdn/theme-settings.php b/sites/all/themes/unl_wdn/theme-settings.php index 8985c0ea49c1b6d26db43f83006b6f8e98d3f4b2..1333f0dd09e22a6165983642c4401b15f85ee66b 100644 --- a/sites/all/themes/unl_wdn/theme-settings.php +++ b/sites/all/themes/unl_wdn/theme-settings.php @@ -51,6 +51,18 @@ function unl_wdn_form_system_theme_settings_alter(&$form, &$form_state) { $form['advanced_settings'] = array( '#type' => 'fieldset', '#title' => t('Advanced Settings'), + 'sidebar_first_width' => array( + '#type' => 'textfield', + '#title' => t('Sidebar first Grid Size'), + '#default_value' => theme_get_setting('sidebar_first_width'), + '#description' => t('Enter only the numeral, for grid4 just enter 4.'), + ), + 'sidebar_second_width' => array( + '#type' => 'textfield', + '#title' => t('Sidebar second Grid Size'), + '#default_value' => theme_get_setting('sidebar_second_width'), + '#description' => t('Enter only the numeral, for grid4 just enter 4.'), + ), 'zen_forms' => array( '#type' => 'checkbox', '#title' => t('Use Zen Forms'), diff --git a/sites/all/themes/unl_wdn/unl_wdn.info b/sites/all/themes/unl_wdn/unl_wdn.info index a3b86329f1a8eed2689e6b1f8dc86f3a837c19eb..30c540f6920eb02b7e1f018dfc79fa140c1b3dc1 100644 --- a/sites/all/themes/unl_wdn/unl_wdn.info +++ b/sites/all/themes/unl_wdn/unl_wdn.info @@ -33,3 +33,5 @@ settings[toggle_favicon] = 0 settings[zen_forms] = 0 settings[use_base] = 1 settings[wdn_beta] = 0 +settings[sidebar_first_width] = 3 +settings[sidebar_second_width] = 3