Skip to content
Snippets Groups Projects
Commit d53581c2 authored by manibharathi ezhimalai ravi's avatar manibharathi ezhimalai ravi
Browse files

Revise the Zebra variable declare in the template preprocessor

parent e63270d5
No related branches found
No related tags found
1 merge request!9462Issue #3472941: Zebra counting of nodes not available
...@@ -1081,6 +1081,14 @@ function template_preprocess_maintenance_task_list(&$variables) { ...@@ -1081,6 +1081,14 @@ function template_preprocess_maintenance_task_list(&$variables) {
* details. * details.
*/ */
function template_preprocess(&$variables, $hook, $info) { function template_preprocess(&$variables, $hook, $info) {
$count = [];
// 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';
// Merge in variables that don't depend on hook and don't change during a // Merge in variables that don't depend on hook and don't change during a
// single page request. // single page request.
// Use the advanced drupal_static() pattern, since this is called very often. // Use the advanced drupal_static() pattern, since this is called very often.
......
...@@ -54,6 +54,8 @@ ...@@ -54,6 +54,8 @@
* displayed after the main title tag that appears in the template. * displayed after the main title tag that appears in the template.
* - view_mode: View mode; for example, "teaser" or "full". * - view_mode: View mode; for example, "teaser" or "full".
* - page: Flag for the full page state. Will be true if view_mode is 'full'. * - page: Flag for the full page state. Will be true if view_mode is 'full'.
* - zebra: Outputs either "even" or "odd". Useful for zebra striping in
* teaser listings.
* *
* @see template_preprocess_node() * @see template_preprocess_node()
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment