0

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..!

asked Aug 6, 2019 at 6:48
2
  • share your block file code..such that it will be easy to debug Commented Aug 6, 2019 at 6:59
  • @aravind Updated the Question. Commented Aug 6, 2019 at 7:02

1 Answer 1

2

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

answered Aug 6, 2019 at 7:03

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.