I got the below error when create the Custom Block for the HTML sitemap.
Error filtering template: Warning: Declaration of Vapor\Sitemap\Block\Sitemap\Category::_getHtml(Magento\Framework\Data\Tree\Node $menuTree, $childrenWrapClass, $limit, $colBrakes = Array) should be compatible with Magento\Theme\Block\Html\Topmenu::_getHtml(Magento\Framework\Data\Tree\Node $menuTree, $childrenWrapClass, $limit, array $colBrakes = Array) in C:\xampp\htdocs\Magento\app\code\Vapor\Sitemap\Block\Sitemap\Category.php on line 62
Block Code
<?php
namespace Vapor\Sitemap\Block\Sitemap;
// use Magento\Framework\View\Element\Template\Context;
use Magento\Framework\View\Element\Template;
// use Vapor\Sitemap\Model\Sitemap\CmsPages;
// use Vapor\Sitemap\Block\Sitemap\Cms;
// use Vapor\Sitemap\Block\Sitemap\Category;
class Index extends Template
{
 const SITEMAP_CUSTOM_TEMPLATE = 'Vapor_Sitemap::sitemap/sitemap.phtml';
 /**
 * [__construct]
 * @param \Magento\Framework\View\Element\Template\Context $context
 * @param \Magento\Framework\Stdlib\DateTime\Timezone $_stdTimezone [description]
 * @param array $data
 */
 protected $getSitemap;
 public function __construct(\Magento\Framework\View\Element\Template\Context $context,\Magento\Framework\Stdlib\DateTime\Timezone $_stdTimezone,
 array $data = [])
 {
 parent::__construct($context, $data);
 $this->getSitemap();
 }
 /**
 * 
 * @return html
 */
 protected function _toHtml()
 { 
 return parent::_toHtml();
 }
 /**
 * @return Mixed data
 */
 public function getSitemap()
 {
 //echo "ComeHere";exit;
 $this->setTemplate(self::SITEMAP_CUSTOM_TEMPLATE);
 return $this;
 }
}
Can anyone help to solve this.
Any help would be appreciated.
Thanks in advance..!
- 
 share your block file code..such that it will be easy to debugaravind– aravind2019年08月06日 06:59:48 +00:00Commented Aug 6, 2019 at 6:59
 - 
 @aravind Updated the Question.AKM– AKM2019年08月06日 07:02:07 +00:00Commented Aug 6, 2019 at 7:02
 
1 Answer 1
make your _getHtml method from the class Vapor\Sitemap\Block\Sitemap\Category look like this:
protected function _getHtml(
 \Magento\Framework\Data\Tree\Node $menuTree,
 $childrenWrapClass,
 $limit,
 array $colBrakes = []
) {
.....
}
you are missing a type hint array on the last parameter