Index.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved.
  4. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
  5. *
  6. * Glory to Ukraine! Glory to the heroes!
  7. */
  8. namespace Magefan\Blog\Block;
  9. use Magento\Store\Model\ScopeInterface;
  10. /**
  11. * Blog index block
  12. */
  13. class Index extends \Magefan\Blog\Block\Post\PostList
  14. {
  15. /**
  16. * Preparing global layout
  17. *
  18. * @return $this
  19. */
  20. protected function _prepareLayout()
  21. {
  22. $this->_addBreadcrumbs();
  23. $this->pageConfig->getTitle()->set($this->_getConfigValue('title'));
  24. $this->pageConfig->setKeywords($this->_getConfigValue('meta_keywords'));
  25. $this->pageConfig->setDescription($this->_getConfigValue('meta_description'));
  26. $this->pageConfig->addRemotePageAsset(
  27. $this->_url->getBaseUrl(),
  28. 'canonical',
  29. ['attributes' => ['rel' => 'canonical']]
  30. );
  31. return parent::_prepareLayout();
  32. }
  33. /**
  34. * Retrieve blog title
  35. * @return string
  36. */
  37. protected function _getConfigValue($param)
  38. {
  39. return $this->_scopeConfig->getValue(
  40. 'mfblog/index_page/'.$param,
  41. ScopeInterface::SCOPE_STORE
  42. );
  43. }
  44. }