getBlogObject()) { return $this->helperData->getPostCollection(Data::TYPE_TOPIC, $topic->getId()); } return null; } /** * @return mixed */ protected function getBlogObject() { if (!$this->_topic) { $id = $this->getRequest()->getParam('id'); if ($id) { $topic = $this->helperData->getObjectByParam($id, null, Data::TYPE_TOPIC); if ($topic && $topic->getId()) { $this->_topic = $topic; } } } return $this->_topic; } /** * @inheritdoc * @throws LocalizedException */ protected function _prepareLayout() { parent::_prepareLayout(); if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) { $topic = $this->getBlogObject(); $topicName = preg_replace('/[^A-Za-z0-9\-]/', ' ', $topic->getName()); if ($topic) { $breadcrumbs->addCrumb($topic->getUrlKey(), [ 'label' => __($topicName), 'title' => __($topicName) ]); } } } /** * @param $meta * * @return array|Phrase|string * @throws NoSuchEntityException */ public function getBlogTitle($meta = false) { $blogTitle = parent::getBlogTitle($meta); $topic = $this->getBlogObject(); if (!$topic) { return $blogTitle; } if ($meta) { if ($this->helperData->getMetaTitleByStoreId($topic->getMetaTitle())) { $blogTitle[] = $this->helperData->getMetaTitleByStoreId($topic->getMetaTitle()); } else { $blogTitle[] = ucfirst($topic->getName()); } return $blogTitle; } return ucfirst($topic->getName()); } }