Example #1
0
 /**
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _prepareLayout()
 {
     parent::_prepareLayout();
     $category = $this->getCategory();
     $title = $category ? $category->getName() : $this->config->getBlogName();
     $metaTitle = $category ? $category->getMetaTitle() ? $category->getMetaTitle() : $category->getName() : $this->config->getBaseMetaTitle();
     $metaDescription = $category ? $category->getMetaDescription() ? $category->getMetaDescription() : $category->getName() : $this->config->getBaseMetaDescription();
     $metaKeywords = $category ? $category->getMetaKeywords() ? $category->getMetaKeywords() : $category->getName() : $this->config->getBaseMetaKeywords();
     $this->pageConfig->getTitle()->set($metaTitle);
     $this->pageConfig->setDescription($metaDescription);
     $this->pageConfig->setKeywords($metaKeywords);
     /** @var \Magento\Theme\Block\Html\Title $pageMainTitle */
     $pageMainTitle = $this->getLayout()->getBlock('page.main.title');
     if ($pageMainTitle) {
         $pageMainTitle->setPageTitle($title);
     }
     /** @var \Magento\Theme\Block\Html\Breadcrumbs $breadcrumbs */
     if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
         $breadcrumbs->addCrumb('home', ['label' => __('Home'), 'title' => __('Go to Home Page'), 'link' => $this->context->getUrlBuilder()->getBaseUrl()])->addCrumb('blog', ['label' => $this->config->getBlogName(), 'title' => $this->config->getBlogName(), 'link' => $this->config->getBaseUrl()]);
         if ($category) {
             $ids = $category->getParentIds();
             $ids[] = 0;
             $parents = $this->categoryCollectionFactory->create()->addFieldToFilter('entity_id', $ids)->addNameToSelect()->excludeRoot()->setOrder('level', 'asc');
             /** @var \Mirasvit\Blog\Model\Category $cat */
             foreach ($parents as $cat) {
                 $breadcrumbs->addCrumb($cat->getId(), ['label' => $cat->getName(), 'title' => $cat->getName(), 'link' => $cat->getUrl()]);
             }
             $breadcrumbs->addCrumb($category->getId(), ['label' => $category->getName(), 'title' => $category->getName()]);
         }
     }
     return $this;
 }
Example #2
0
 /**
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _prepareLayout()
 {
     parent::_prepareLayout();
     $title = $metaTitle = __("Search results for: '%1'", $this->getRequest()->getParam('q'));
     $metaDescription = $this->config->getBaseMetaDescription();
     $metaKeywords = $this->config->getBaseMetaKeywords();
     $this->pageConfig->getTitle()->set($metaTitle);
     $this->pageConfig->setDescription($metaDescription);
     $this->pageConfig->setKeywords($metaKeywords);
     /** @var \Magento\Theme\Block\Html\Title $pageMainTitle */
     $pageMainTitle = $this->getLayout()->getBlock('page.main.title');
     if ($pageMainTitle) {
         $pageMainTitle->setPageTitle($title);
     }
     /** @var \Magento\Theme\Block\Html\Breadcrumbs $breadcrumbs */
     if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
         $breadcrumbs->addCrumb('home', ['label' => __('Home'), 'title' => __('Go to Home Page'), 'link' => $this->context->getUrlBuilder()->getBaseUrl()])->addCrumb('blog', ['label' => $this->config->getBlogName(), 'title' => $this->config->getBlogName(), 'link' => $this->config->getBaseUrl()])->addCrumb('search', ['label' => $title, 'title' => $title]);
     }
     return $this;
 }