function template_preprocess

cis7 theme.inc template_preprocess(&$variables, $hook)
cle7 theme.inc template_preprocess(&$variables, $hook)
elmsmedia7 theme.inc template_preprocess(&$variables, $hook)
icor7 theme.inc template_preprocess(&$variables, $hook)
meedjum_blog7 theme.inc template_preprocess(&$variables, $hook)
mooc7 theme.inc template_preprocess(&$variables, $hook)

Adds a default set of helper variables for variable processors and templates.

This function is called for theme hooks implemented as templates only, not for theme hooks implemented as functions. This preprocess function is the first in the sequence of preprocessing and processing functions that is called when preparing variables for a template. See theme() for more details about the full sequence.

See also

theme()

template_process()

2 calls to template_preprocess()
devel_themer_theme_twin in sites/all/modules/ulmus/devel_themer/devel_themer.module
Nearly clones the Drupal API theme() function.
theme in includes/theme.inc
Generates themed output.
2 string references to 'template_preprocess'
alpha_theme in sites/all/themes/ulmus/omega/alpha/template.php
Implements hook_theme().
rubik_theme in sites/all/themes/ulmus/rubik/template.php
Implementation of hook_theme().

File

includes/theme.inc, line 2343
The theme system, which controls the output of Drupal.

Code

function template_preprocess(&$variables, $hook) {
  global $user;
  static $count = array();

  // Track run count for each hook to provide zebra striping. See
  // "template_preprocess_block()" which provides the same feature specific to
  // blocks.
  $count[$hook] = isset($count[$hook]) && is_int($count[$hook]) ? $count[$hook] : 1;
  $variables['zebra'] = ($count[$hook] % 2) ? 'odd' : 'even';
  $variables['id'] = $count[$hook]++;

  // Tell all templates where they are located.
  $variables['directory'] = path_to_theme();

  // Initialize html class attribute for the current hook.
  $variables['classes_array'] = array(drupal_html_class($hook));

  // Merge in variables that don't depend on hook and don't change during a
  // single page request.
  // Use the advanced drupal_static() pattern, since this is called very often.
  static $drupal_static_fast;
  if (!isset($drupal_static_fast)) {
    $drupal_static_fast['default_variables'] = &drupal_static(__FUNCTION__);
  }
  $default_variables = &$drupal_static_fast['default_variables'];
  // Global $user object shouldn't change during a page request once rendering
  // has started, but if there's an edge case where it does, re-fetch the
  // variables appropriate for the new user.
  if (!isset($default_variables) || ($user !== $default_variables['user'])) {
    $default_variables = _template_preprocess_default_variables();
  }
  $variables += $default_variables;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.