0

When i enable the developer mode on my Magento 2.3.3 instance i get the following error message when calling category pages in webbrowser:

Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'block', attribute 'remove': The attribute 'remove' is not allowed.
Line: 976

Element 'block', attribute 'remove': The attribute 'remove' is not allowed.
Line: 980


Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'block', attribute 'remove': The attribute 'remove' is not allowed.
Line: 976

Element 'block', attribute 'remove': The attribute 'remove' is not allowed.
Line: 980

<pre>#1 Magento\Framework\Config\Dom->__construct() called at [vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:116]
#2 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() called at [vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:66]
#3 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() called at [vendor/magento/framework/ObjectManager/ObjectManager.php:56]
#4 Magento\Framework\ObjectManager\ObjectManager->create() called at [vendor/magento/framework/Config/DomFactory.php:43]
#5 Magento\Framework\Config\DomFactory->createDom() called at [vendor/magento/framework/View/Model/Layout/Update/Validator.php:141]
#6 Magento\Framework\View\Model\Layout\Update\Validator->isValid() called at [vendor/magento/framework/View/Model/Layout/Merge.php:494]
#7 Magento\Framework\View\Model\Layout\Merge->_validateMergedLayout() called at [vendor/magento/framework/View/Model/Layout/Merge.php:470]
#8 Magento\Framework\View\Model\Layout\Merge->load() called at [generated/code/Magento/Framework/View/Model/Layout/Merge/Interceptor.php:193]
#9 Magento\Framework\View\Model\Layout\Merge\Interceptor->load() called at [vendor/magento/framework/View/Layout/Builder.php:86]
#10 Magento\Framework\View\Layout\Builder->loadLayoutUpdates() called at [vendor/magento/framework/View/Layout/Builder.php:63]
#11 Magento\Framework\View\Layout\Builder->build() called at [vendor/magento/framework/View/Page/Config.php:224]
#12 Magento\Framework\View\Page\Config->build() called at [vendor/magento/framework/View/Page/Config.php:587]
#13 Magento\Framework\View\Page\Config->getElementAttribute() called at [vendor/magento/framework/View/Page/Config.php:545]
#14 Magento\Framework\View\Page\Config->addBodyClass() called at [vendor/magento/module-catalog/Controller/Category/View.php:217]
#15 Magento\Catalog\Controller\Category\View->execute() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#16 Magento\Catalog\Controller\Category\View\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#17 Magento\Catalog\Controller\Category\View\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#18 Magento\Catalog\Controller\Category\View\Interceptor->___callPlugins() called at [generated/code/Magento/Catalog/Controller/Category/View/Interceptor.php:26]
#19 Magento\Catalog\Controller\Category\View\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:108]
#20 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#21 Magento\Catalog\Controller\Category\View\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#22 Magento\Catalog\Controller\Category\View\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#23 Magento\Catalog\Controller\Category\View\Interceptor->___callPlugins() called at [generated/code/Magento/Catalog/Controller/Category/View/Interceptor.php:39]
#24 Magento\Catalog\Controller\Category\View\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:159]
#25 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:99]
#26 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#27 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#28 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php:94]
#29 Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#30 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:69]
#31 Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#32 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#33 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#34 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:137]
#35 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
#36 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:261]
#37 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:40]
</pre>

Im using a child theme based on the porto theme. My app/design/frontend/Smartwave/porto_child/Magento_Catalog/layout/catalog_category_view.xml looks as follows:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="page.top">
             <block class="Magento\Catalog\Block\Category\View" name="category_banner" template="category/banner.phtml" ifconfig="porto_settings/category/category_description" before="-"/>
        </referenceContainer>
        <referenceContainer name="content">
            <!-- <block class="Smartwave\Porto\Block\Template" name="category_overview" template="Magento_Catalog::category/view.phtml"/> -->
            <block class="Magento\Catalog\Block\Category\View" name="category_desc_main_column" template="category/desc_main_column.phtml" ifconfig="porto_settings/category/category_description" before="category.products" remove="1"/>
        </referenceContainer>
        <referenceBlock name="category.image" remove="1"/>
        <referenceContainer name="sidebar.main" remove="1">
            <block class="Smartwave\Porto\Block\Template" name="category_view_custom_block" after="-" template="Magento_Catalog::category/custom_block.phtml" remove="1"/>
        </referenceContainer>
    </body>
    <move element="category.view.container" destination="content"  after="-"/>
</page>

How can I get rid of the error messages, what have I missed?

1

3 Answers 3

1

Where you found this remove="1" ???

Should be

remove="true"

Like:

<referenceBlock name="category.image" remove="true"/>

Reference:

https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/xml-manage.html#layout_markup_rearrange

3
  • remove="1" were the default values in the vendor file catalog_category_view.xml of the installed Porto Theme. I think the problems are caused by these lines in the catalog_category_view.xml: <block class="Magento\Catalog\Block\Category\View" name="category_desc_main_column" template="category/desc_main_column.phtml" ifconfig="porto_settings/category/category_description" before="category.products" remove="1"/> and <block class="Smartwave\Porto\Block\Template" name="category_view_custom_block" after="-" template="Magento_Catalog::category/custom_block.phtml" remove="1"/>
    – max stern
    Mar 9, 2020 at 21:29
  • so just remove remove="1" from referenceBlock parts like its says in the error.
    – BartZalas
    Mar 9, 2020 at 21:40
  • Thanks a lot, I found the mistake: For some reason the catalog_product_view.xml of my child theme ([...]/Smartwave/**porto_child**/Magento_Catalog/layout/catalog_product_view.xml) is not loaded. Instead, the file is loaded from the parent theme at [...]/Smartwave/**porto**/Magento_Catalog/layout/catalog_product_view.xml. I had not made any changes there yet
    – max stern
    Mar 9, 2020 at 23:15
1

To solve this problem I had to replace the old syntax remove="1" against the modern one: remove="true".

I also removed the other remove="1" attributes out of my first post from the block elements and replaced them with a single statement:

<referenceBlock name="category.image" remove="true" />

@BartZalas has been a big help and pointed me to the appropriate place in the Magento 2.3.x documentation: Common layout customization tasks, Rearrange elements

My catalog_category_view.xml file now works as expected and looks like this:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
            <referenceContainer name="page.top">
                 <block class="Magento\Catalog\Block\Category\View" name="category_banner" template="category/banner.phtml" ifconfig="porto_settings/category/category_description" before="-"/>
            </referenceContainer>
            <referenceContainer name="content">
                <!-- <block class="Smartwave\Porto\Block\Template" name="category_overview" template="Magento_Catalog::category/view.phtml"/> -->
                <block class="Magento\Catalog\Block\Category\View" name="category_desc_main_column" template="category/desc_main_column.phtml" ifconfig="porto_settings/category/category_description" before="category.products" />
            </referenceContainer>
            <referenceBlock name="category.image" remove="true" />
            <referenceContainer name="sidebar.main">
                <block class="Smartwave\Porto\Block\Template" name="category_view_custom_block" after="-" template="Magento_Catalog::category/custom_block.phtml" />
            </referenceContainer>
        </body>
        <move element="category.view.container" destination="content"  after="-"/>
</page>
1
Element 'block', attribute 'remove': The attribute 'remove' is not allowed.

So Block tag not allow remove attribute.

If you want to remove follow this

<referenceBlock name=”block_name” remove=”true”/>

Source link click here

I Hope This Helps You.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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