Can anyone explain me what does the below coding mean?

$html = array();
$combineClasses = array();

    $combineClasses[] = 'level' . $level;
    if ($this->_isCurrentCategory($category)) {
        $combineClasses[] = 'active';
    } else {
        $combineClasses[] = $this->isCategoryActive($category) ? 'parent' : 'inactive';
    $levelClass[] = implode('-', $combineClasses);

    if ($category->hasChildren()) {
        $levelClass[] = 'has-children';

    $levelClass = array_merge($levelClass, $combineClasses);

    $levelClass[] = $this->_getClassNameFromCategoryName($category);

1 Answer 1


This code generates the CSS classes to be added to the category items in the top menu.

A pseudo code could be:

  • add a level class
  • if it is the current category add an active class
  • else add a parent class if it is a parent category of the current category or an inactive if not
  • add a has-children class if the category has childrne
  • I suppose it adds classes base on the category name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.