function _megamenu_count_attributes in Megamenu 6.2
Same name and namespace in other branches
- 6 megamenu.utilities.inc \_megamenu_count_attributes()
- 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()
- theme_megamenu_menu_tree in ./
megamenu.module - Theme a menu tree
File
- ./
megamenu.utilities.inc, line 151 - 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 = ' leaf-' . $position . ' first';
}
else {
if ($position == $total_count - 1) {
$order = ' leaf-' . $position . ' last';
}
else {
$order = ' leaf-' . $position;
}
}
return $position . $zebra . $halves . $order;
}