0

1 exception(s): Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'Magento_Catalog::catalog/wysiwyg/js.phtml' in module: 'Magento_Backend' block's name: 'template_0'

1 exception(s): Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'Magento_Catalog::catalog/wysiwyg/js.phtml' in module: 'Magento_Backend' block's name: 'template_0'

Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'Magento_Catalog::catalog/wysiwyg/js.phtml' in module: 'Magento_Backend' block's name: 'template_0'
#0 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/View/Element/Template.php(301): Magento\Framework\View\Element\Template->fetchView(false)
#1 /var/www/html/magento/magento2-2.3.0/app/code/Magento/Backend/Block/Template.php(129): Magento\Framework\View\Element\Template->_toHtml()
#2 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/View/Element/AbstractBlock.php(668): Magento\Backend\Block\Template->_toHtml()
#3 /var/www/html/magento/magento2-2.3.0/app/code/Sm/MegaMenu/Block/Adminhtml/MenuItems/Edit/Tab/Form.php(644): Magento\Framework\View\Element\AbstractBlock->toHtml()
#4 /var/www/html/magento/magento2-2.3.0/app/code/Magento/Backend/Block/Widget/Form.php(144): Sm\MegaMenu\Block\Adminhtml\MenuItems\Edit\Tab\Form->_prepareForm()
#5 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/View/Element/AbstractBlock.php(667): Magento\Backend\Block\Widget\Form->_beforeToHtml()
#6 /var/www/html/magento/magento2-2.3.0/app/code/Sm/MegaMenu/Block/Adminhtml/MenuItems/Edit/Tabs.php(89): Magento\Framework\View\Element\AbstractBlock->toHtml()
#7 /var/www/html/magento/magento2-2.3.0/app/code/Sm/MegaMenu/Block/Adminhtml/MenuItems/Edit/Tabs.php(79): Sm\MegaMenu\Block\Adminhtml\MenuItems\Edit\Tabs->_getTabHtml('\\Form')
#8 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/View/Element/AbstractBlock.php(273): Sm\MegaMenu\Block\Adminhtml\MenuItems\Edit\Tabs->_prepareLayout()
#9 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/View/Layout.php(760): Magento\Framework\View\Element\AbstractBlock->setLayout(Object(Magento\Framework\View\Layout\Interceptor))
#10 /var/www/html/magento/magento2-2.3.0/app/code/Sm/MegaMenu/Controller/Adminhtml/MenuItems/Edit.php(182): Magento\Framework\View\Layout->createBlock('\\Sm\\MegaMenu\\Bl...')
#11 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/App/Action/Action.php(108): Sm\MegaMenu\Controller\Adminhtml\MenuItems\Edit->execute()
#12 /var/www/html/magento/magento2-2.3.0/app/code/Magento/Backend/App/AbstractAction.php(231): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#13 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))
#14 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Sm\MegaMenu\Controller\Adminhtml\MenuItems\Edit\Interceptor->___callParent('dispatch', Array)
#15 /var/www/html/magento/magento2-2.3.0/app/code/Magento/Backend/App/Action/Plugin/Authentication.php(143): Sm\MegaMenu\Controller\Adminhtml\MenuItems\Edit\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#16 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/Interception/Interceptor.php(135): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Sm\MegaMenu\Controller\Adminhtml\MenuItems\Edit\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#17 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Sm\MegaMenu\Controller\Adminhtml\MenuItems\Edit\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#18 /var/www/html/magento/magento2-2.3.0/generated/code/Sm/MegaMenu/Controller/Adminhtml/MenuItems/Edit/Interceptor.php(26): Sm\MegaMenu\Controller\Adminhtml\MenuItems\Edit\Interceptor->___callPlugins('dispatch', Array, NULL)
#19 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/App/FrontController.php(159): Sm\MegaMenu\Controller\Adminhtml\MenuItems\Edit\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#20 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/App/FrontController.php(99): Magento\Framework\App\FrontController->processRequest(Object(Magento\Framework\App\Request\Http), Object(Sm\MegaMenu\Controller\Adminhtml\MenuItems\Edit\Interceptor))
#21 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#22 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#23 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#24 /var/www/html/magento/magento2-2.3.0/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#25 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#26 /var/www/html/magento/magento2-2.3.0/lib/internal/Magento/Framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#27 /var/www/html/magento/magento2-2.3.0/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#28 {main}
3
  • 1
    You have the issue in this module app/code/Sm/MegaMenu. Jan 4 '19 at 11:17
  • what was the issues Jan 4 '19 at 12:49
  • i havn't change any things in that part Jan 4 '19 at 12:50
5

@athhar you can simply change the code for SM_MegaMenu as detailed below.

File 1: megamenu_menuitems_edit.xml - Remove following lines from body tag.

<referenceContainer name="js">
        <block class="Magento\Framework\View\Element\Template" template="Magento_Catalog::catalog/wysiwyg/js.phtml" name="catalog.wysiwyg.js"/>
</referenceContainer>

File 2: Sm\MegaMenu\Block\Adminhtml\MenuItems\Edit\Tab\Form.php - Remove code

$textarea = $fieldset->addField(
        'content',
        'textarea',
        [
            'label' => __('Content'),
            'title' => __('Content'),
            'style' => 'height:14em;',
            'name'  => 'content',
            'class' => 'megamenu_content',
            'note'  => 'Content width must match the number of column pixel in the Column Number field',
            'disabled' => $isElementDisabled
        ]
    );
    $textarea->getAfterElementHtml();
    $html = $this->_blockFactory->createBlock(
        '\Magento\Backend\Block\Widget\Button',
        '',
        [
            'data' => [
                'label' => __('WYSIWYG Editor'),
                'type' => 'button',
                'disabled' => $isElementDisabled,
                'class' => 'action-wysiwyg',
                'onclick' => 'catalogWysiwygEditor.open(\'' . $this->_backendData->getUrl(
                        'catalog/product/wysiwyg'
                    ) . '\', \''.$textarea->getId(). '\')',
            ]
        ]
    )->toHtml();

    $block_js = $this->_blockFactory->createBlock('\Magento\Backend\Block\Template')
        ->setTemplate('Magento_Catalog::catalog/wysiwyg/js.phtml');
    $html .= $block_js->toHtml();
    $textarea->setAfterElementHtml($html);

And replace it with below code

$textarea = $fieldset->addField(
        'content',
        'editor',
        [
            'label' => __('Content'),
            'title' => __('Content'),
            'style' => 'height:14em;',
            'name'  => 'content',
            'class' => 'megamenu_content',
            'wysiwyg' => true,
            'config' => $this->_wysiwygConfig->getConfig(),
            'note'  => 'Content width must match the number of column pixel in the Column Number field',
            'disabled' => $isElementDisabled
        ]
    );

in same file include class \Magento\Cms\Model\Wysiwyg\Config in constructor as described below

protected $_wysiwygConfig;
public function __construct(
...
\Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig,
array $data = []
) {
    $this->_wysiwygConfig = $wysiwygConfig;
    parent::__construct(..., $data);
}
0

@Rizwan Dhuka Thanks for suggestions. In order to make it compatible with TinyMCE4 please change the following lines in app/code/Sm/MegaMenu/Block/Adminhtml/MenuItems/Edit/Tab/Form.php:

require([
        "query",
        "tinymce",
        "Magento_UI/js/modal/modal",

to

require([
        "query",
        "wysiwygAdapter",
        "Magento_UI/js/modal/modal",

(replace tinymce with wysiwygAdapter around line 646)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.