Add back Zebra counting of nodes

Created on 8 September 2024, 3 months ago
Updated 12 September 2024, 3 months ago

Problem/Motivation

In D7 there was a hook counter for zebra variable.

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';

This has been removed in D10 for unknown reasons. I need the add/even value in node.html.twig and I have no idea how I could re-implement this. Can someone share an idea why it was removed and if we could add this back?

Currently the node template does not know if it is the odd or even one.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

โœจ Feature request
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Themeย  โ†’

Last updated 4 days ago

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany marc.bau

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024