/** * Check if this category is in the currently active section (e.g. it is * either current or one of it's children or products is currently being * viewed). * * @return bool */ public function isSection() { // First check if we are currently viewing a product $product = Catalogue_Controller::get_current_product(); if ($product->ID && $product->Categories()->exists()) { $ancestors = $product->Categories()->first()->getAncestors()->column(); $ancestors[] = $product->Categories()->first()->ID; } else { // Get a map of ancestors $ancestors = Catalogue_Controller::get_current_category()->getAncestors()->column(); if ($this->isCurrent()) { $ancestors[] = $this->ID; } } return in_array($this->ID, $ancestors) ? true : false; }