/** * Add default body classes for current page layout * * @return $this */ protected function addDefaultBodyClasses() { $this->pageConfig->addBodyClass($this->request->getFullActionName('-')); $pageLayout = $this->getPageLayout(); if ($pageLayout) { $this->pageConfig->addBodyClass('page-layout-' . $pageLayout); } return $this; }
/** * Prepare global layout * * @return $this */ protected function _prepareLayout() { $page = $this->getPage(); $this->_addBreadcrumbs($page); $this->pageConfig->addBodyClass('cms-' . $page->getIdentifier()); $this->pageConfig->getTitle()->set($page->getTitle()); $this->pageConfig->setKeywords($page->getMetaKeywords()); $this->pageConfig->setDescription($page->getMetaDescription()); $pageMainTitle = $this->getLayout()->getBlock('page.main.title'); if ($pageMainTitle) { // Setting empty page title if content heading is absent $cmsTitle = $page->getContentHeading() ?: ' '; $pageMainTitle->setPageTitle($this->escapeHtml($cmsTitle)); } return parent::_prepareLayout(); }
/** * Prepare global layout * * @return $this */ protected function _prepareLayout() { $page = $this->getPage(); // show breadcrumbs if ($this->_scopeConfig->getValue('web/default/show_cms_breadcrumbs', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) && ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) && $page->getIdentifier() !== $this->_scopeConfig->getValue('web/default/cms_home_page', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) && $page->getIdentifier() !== $this->_scopeConfig->getValue('web/default/cms_no_route', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) { $breadcrumbs->addCrumb('home', array('label' => __('Home'), 'title' => __('Go to Home Page'), 'link' => $this->_storeManager->getStore()->getBaseUrl())); $breadcrumbs->addCrumb('cms_page', array('label' => $page->getTitle(), 'title' => $page->getTitle())); } $this->pageConfig->addBodyClass('cms-' . $page->getIdentifier()); $head = $this->getLayout()->getBlock('head'); if ($head) { $head->setTitle($page->getTitle()); $head->setKeywords($page->getMetaKeywords()); $head->setDescription($page->getMetaDescription()); } $pageMainTitle = $this->getLayout()->getBlock('page.main.title'); if ($pageMainTitle) { // Setting empty page title if content heading is absent $cmsTitle = $page->getContentHeading() ?: ' '; $pageMainTitle->setPageTitle($this->escapeHtml($cmsTitle)); } return parent::_prepareLayout(); }
/** * @return \Magento\Framework\View\Result\Page */ public function execute() { $this->pageConfig->addBodyClass('swagger-section'); return $this->pageFactory->create(); }
public function testAddBodyClass() { $className = 'test class'; $this->assertInstanceOf('Magento\\Framework\\View\\Page\\Config', $this->model->addBodyClass($className)); $this->assertEquals('test-class', $this->model->getElementAttribute('body', 'class')); }
/** * {@inheritdoc} */ public function addBodyClass($className) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'addBodyClass'); if (!$pluginInfo) { return parent::addBodyClass($className); } else { return $this->___callPlugins('addBodyClass', func_get_args(), $pluginInfo); } }
/** * Add body class to page configuration api * * @param string $bodyClass * @return $this */ public function addBodyClass($bodyClass) { $this->pageConfig->addBodyClass($bodyClass); return $this; }