Project

General

Profile

« Previous | Next » 

Revision 1dc9554f

Added by Andreas Kohlbecker over 10 years ago

theme customization improved - layout adapts to image sizes

View differences:

7.x/themes/zen_dataportal/template.php
106 106
 *   name of the image, see _zen_dataportal_imagenames() for possible values
107 107
 * @param $variables
108 108
 *   An array of variables to pass to the theme template.
109
 * @param $attributes_key
110
 *
109
 * @param $css_selector
110
 *   The dom element to apply the image as background image
111 111
 * @param $background_style
112
 *   Addtional css setting for the background css attribute, default is  'scroll repeat'
112 113
 *
113 114
 * @see _zen_dataportal_imagenames() for possible values
114 115
 */
115
function _set_image_url($which_image, &$variables, $attributes_key = NULL, $background_style = 'scroll repeat') {
116
function _set_image_url($which_image, &$variables, $css_selector = NULL, $background_style = 'scroll repeat') {
116 117

  
117
  if($attributes_key) {
118
    $variables[$attributes_key] = '';
119
  }
120 118

  
121 119
  if (!theme_get_setting('default_' . $which_image)) {
122 120
    $path = theme_get_setting($which_image . '_path');
......
126 124
      }
127 125
      if(isset($url)) {
128 126
        $variables[$which_image . '_url'] = $url;
129
        if($attributes_key) {
127

  
128
        if($css_selector) {
129
          if(!isset($variables['inline_styles'])) {
130
            $variables['inline_styles'] = array();
131
          }
130 132
          // FIXME is not save only works if no other style given e.g. html.php $attributes
131
          $variables[$attributes_key] = ' style="background: white url(' . $url .')  ' . $background_style . ';"';
133
          $variables['inline_styles'][] = $css_selector . ' {background: white url(' . $url .')  ' . $background_style . ';}';
132 134
        }
133 135
      }
134 136

  
......
141 143
function _add_inline_styles(&$variables) {
142 144

  
143 145
  $css = array();
144
  $variables['inline_styles'] = '';
146
  if(!isset($variables['inline_styles'])) {
147
    $variables['inline_styles'] = array();
148
  }
145 149

  
146 150
  // site_name
147 151
  if(theme_get_setting('site_name_color')) {
148
      $css[] = "#site-name a span {color:" . theme_get_setting('site_name_color') . ';}';
152
      $variables['inline_styles'][] = "#site-name a span {color:" . theme_get_setting('site_name_color') . ';}';
153
  }
154
  if(theme_get_setting('logo_size')) {
155
    $logo_size = theme_get_setting('logo_size');
156
    $variables['inline_styles'][] = '#header {background-position:' . $logo_size['width'] . 'px 0;}';
157
    $variables['inline_styles'][] = '#main-menu {padding-left:' . $logo_size['width'] . 'px;}';
149 158
  }
150

  
151
  $variables['inline_styles'] = '<style type="text/css">'. "\n" . implode("\n", $css) . '</style>';
152 159
}
153 160

  
154 161

  
......
179 186
 *   The name of the template being rendered ("html" in this case.)
180 187
 */
181 188
function zen_dataportal_preprocess_html(&$variables, $hook) {
182
  _set_image_url('body_background', $variables, 'attributes');
189
  _set_image_url('body_background', $variables, 'body');
190
  _set_image_url('page_background', $variables, '#page');
191
  _set_image_url('banner', $variables, '#header', 'scroll no-repeat content-box');
183 192
  _add_inline_styles($variables);
184 193
}
185 194

  
......
192 201
 *   The name of the template being rendered ("page" in this case.)
193 202
 */
194 203
function zen_dataportal_preprocess_page(&$variables, $hook) {
195
  _set_image_url('banner', $variables, 'banner_attributes', 'scroll no-repeat content-box');
196
  _set_image_url('page_background', $variables, 'page_attributes');
197 204
}
198 205

  
199 206
/**

Also available in: Unified diff