Skip to content

Commit

Permalink
Merge pull request #5 from Space48/feature/contentFilter
Browse files Browse the repository at this point in the history
Image Fix
  • Loading branch information
diazwatson authored Jun 8, 2018
2 parents 075043b + d8e3628 commit b38a117
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion Block/Html/TopMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Magento\Catalog\Helper\Category as HelperCategory;
use Magento\Catalog\Model\Category;
use Magento\Cms\Model\BlockRepository;
use Magento\Cms\Model\Template\FilterProvider;
use Magento\Framework\Data\Tree\Node\Collection as NodeCollection;
use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection;
use Magento\Framework\Exception\NoSuchEntityException;
Expand All @@ -35,11 +36,17 @@ class TopMenu extends Template
*/
private $blockRepository;

/**
* @var \Magento\Cms\Model\Template\FilterProvider
*/
protected $filterProvider;

/**
* Topmenu constructor.
*
* @param HelperCategory|Category $categoryHelper
* @param BlockRepository $blockRepository
* @param FilterProvider $filterProvider
* @param Context $context
* @param array $data
*
Expand All @@ -48,12 +55,14 @@ class TopMenu extends Template
public function __construct(
HelperCategory $categoryHelper,
BlockRepository $blockRepository,
FilterProvider $filterProvider,
Context $context,
$data = []
)
{
$this->categoryHelper = $categoryHelper;
$this->blockRepository = $blockRepository;
$this->filterProvider = $filterProvider;
parent::__construct($context, $data);
}

Expand Down Expand Up @@ -96,9 +105,14 @@ public function getCmsMenu($category)
{
$block = null;
$blockId = $category->getData('cms_block_menu');
$storeId = $this->_storeManager->getStore()->getId();
if ($blockId) {
$block = $this->blockRepository->getById($blockId);
}
return ($block && $block->getData('is_active')) ? $block->getContent() : null;
return ($block && $block->getData('is_active'))
? $this->filterProvider->getBlockFilter()
->setStoreId($storeId)
->filter($block->getContent())
: null;
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "space48/cmsmenu",
"description": "Magento 2 module that replaces the core top navigation sub menus for CMS blocks.",
"type": "magento2-module",
"version": "1.0.8",
"version": "1.0.9",
"license": [
"proprietary"
],
Expand Down

0 comments on commit b38a117

Please sign in to comment.