You are here

function _megamenu_count_attributes in Megamenu 6

Same name and namespace in other branches
  1. 6.2 megamenu.utilities.inc \_megamenu_count_attributes()
  2. 7 megamenu.utilities.inc \_megamenu_count_attributes()

Determine the zebra, half, and order attributes of an item.

This is a helper function to generate count based classes based on an items position in the sequence and the total count of items. These classes consist of an item's zebra (even/odd), half (half1/half2), and order (first/last).

Parameters

$count: An item's numerical position within a sequence.

$leafcount: The total count of items

Return value

zebra (event/odd), halves (half1/half2), and order (first/last). clases are returned as a space delimited list.

1 call to _megamenu_count_attributes()
megamenu_theme_menu_tree in ./megamenu.module
Theme a menu tree

File

./megamenu.utilities.inc, line 88
Helper/utility functions

Code

function _megamenu_count_attributes($position, $total_count) {
  $zebra = $position % 2 ? ' even' : ' odd';
  $halves = $position < $total_count / 2 ? ' half-1' : ' half-2';
  if ($position == 0) {
    $order = ' first';
  }
  else {
    if ($position == $total_count - 1) {
      $order = ' last';
    }
    else {
      $order = '';
    }
  }
  return $zebra . $halves . $order;
}