public function getTemplate() { $parentTemplate = parent::getTemplate(); $isEmpty = empty($this->template); if (!$isEmpty && $this->template != $parentTemplate) { return $this->template; } if ($isEmpty && 1 === count($this->related)) { return current($this->related)->getTemplate(); } else { return $parentTemplate; } }