/** * @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; }
/** * @return $this * * @throws \Magento\Framework\Exception\LocalizedException */ protected function _prepareLayout() { parent::_prepareLayout(); $tag = $this->getTag(); $this->pageConfig->getTitle()->set(__('Tag: %1', $tag->getName())); if ($tag && ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs'))) { $breadcrumbs->addCrumb('home', ['label' => __('Home'), 'title' => __('Go to Home Page'), 'link' => $this->context->getUrlBuilder()->getBaseUrl()]); $breadcrumbs->addCrumb('blog', ['label' => __('Blog'), 'title' => __('Blog')]); $breadcrumbs->addCrumb($tag->getId(), ['label' => __('Tag: %1', $tag->getName()), 'title' => __('Tag: %1', $tag->getName())]); } return $this; }
public function __construct(Template\Context $context, \Celebros\ConversionPro\Helper\Data $helper, \Celebros\ConversionPro\Helper\Search $searchHelper, \Magento\Framework\Registry $registry, array $data = []) { $this->helper = $helper; $this->searchHelper = $searchHelper; $this->registry = $registry; $this->url = $context->getUrlBuilder(); parent::__construct($context, $data); }
/** * @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; }
/** * Constructor * * @param View\Element\Template\Context $context * @param View\LayoutFactory $layoutFactory * @param View\Layout\ReaderPool $layoutReaderPool * @param Framework\Translate\InlineInterface $translateInline * @param View\Layout\BuilderFactory $layoutBuilderFactory * @param View\Layout\GeneratorPool $generatorPool * @param View\Page\Config\RendererFactory $pageConfigRendererFactory * @param View\Page\Layout\Reader $pageLayoutReader * @param string $template * @param bool $isIsolated * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct(View\Element\Template\Context $context, View\LayoutFactory $layoutFactory, View\Layout\ReaderPool $layoutReaderPool, Framework\Translate\InlineInterface $translateInline, View\Layout\BuilderFactory $layoutBuilderFactory, View\Layout\GeneratorPool $generatorPool, View\Page\Config\RendererFactory $pageConfigRendererFactory, View\Page\Layout\Reader $pageLayoutReader, $template, $isIsolated = false) { $this->request = $context->getRequest(); $this->assetRepo = $context->getAssetRepository(); $this->logger = $context->getLogger(); $this->urlBuilder = $context->getUrlBuilder(); $this->pageConfig = $context->getPageConfig(); $this->pageLayoutReader = $pageLayoutReader; $this->viewFileSystem = $context->getViewFileSystem(); $this->pageConfigRendererFactory = $pageConfigRendererFactory; $this->template = $template; parent::__construct($context, $layoutFactory, $layoutReaderPool, $translateInline, $layoutBuilderFactory, $generatorPool, $isIsolated); $this->initPageConfigReader(); }