function _megamenu_count_attributes in Megamenu 7
Same name and namespace in other branches
- 6.2 megamenu.utilities.inc \_megamenu_count_attributes()
- 6 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
int $position: An item's numerical position within a sequence.
int $total_count: The total count of items.
Return value
string 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 151 - Helper/utility functions for Megamenu.
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';
}
elseif ($position == $total_count - 1) {
$order = ' leaf-' . $position . ' last';
}
else {
$order = ' leaf-' . $position;
}
return $position . $zebra . $halves . $order;
}