I have a small menu problem. The active tabs do not match the active class. If I disable the static_block
cache it works again, so it actually looks like the menu is cached and continues to display the content that is cached regardless of the tab selected.
I tried to put cacheable=false
on the block of the topmenu concerned in the default.xml
layout but this didn't change anything.
if someone has already had this problem or has a lead...
Edit :
I fixed it quickly, by removing the topmenu from the cache, (if I understood what I did correctly) but as you can see it's not terrible, but it works very well now
<?php
namespace MyNamespace\Indo\Block\Html;
use Magento\Framework\Data\Tree\NodeFactory;
use Magento\Framework\Data\TreeFactory;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\LayoutFactory;
use TemplateMonster\Megamenu\Helper\Data;
class Topmenu extends \Magento\Theme\Block\Html\Topmenu
{
public $_helper;
public $_layoutFactory;
public function __construct(
Template\Context $context,
NodeFactory $nodeFactory,
TreeFactory $treeFactory,
Data $helper,
LayoutFactory $layoutFactory,
array $data = []
)
{
parent::__construct($context, $nodeFactory, $treeFactory, $data);
$this->_helper = $helper;
$this->_layoutFactory = $layoutFactory;
}
/**
* Get block cache life time
*
* @return int
* @since 100.1.0
*/
protected function getCacheLifetime()
{
return 0;
}
}