You are here

function template_preprocess_styles in Styles 7.2

Same name and namespace in other branches
  1. 6.2 themes/styles.theme.inc \template_preprocess_styles()
  2. 6 themes/styles.theme.inc \template_preprocess_styles()
  3. 7 styles.module \template_preprocess_styles()

File

themes/styles.theme.inc, line 20
styles.theme.inc Theme and preprocess functions for the Styles project.

Code

function template_preprocess_styles(&$variables) {

  // If we have a Styles object instance already, then honor that.
  // Otherwise, we'll build a new Styles object instance from our settings.
  $variables['instance'] = $variables['instance'] ? $variables['instance'] : styles_instance($variables);

  // Add the style name to the wrapper's classes array.
  $variables['instance']
    ->arrayPush('classes', $variables['style_name']);
  if ($variables['instance']) {

    // Prefix and suffix are for the wrapper, such as div or span.
    $variables['prefix'] = $variables['instance']
      ->getPrefix();
    $variables['suffix'] = $variables['instance']
      ->getSuffix();

    // Render the output for the template file.
    $variables['output'] = $variables['instance']
      ->display(TRUE);
  }
  else {

    // We have no instance, thus nothing to output.
    $variables['output'] = '';
  }
}