1

Does somebody know why the xml bellow causes blank page on search result page ?

Im using luma theme and have custom theme with Magento_Theme/layout/default.xml.

All pages are shown correctly exept search result like catalogsearch/result/?q=xxx.

<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <referenceContainer name="header.panel">
        <block class="Magento\Framework\View\Element\Html\Links" name="header.links">
            <arguments>
                <argument name="css_class" xsi:type="string">header links</argument>
            </arguments>
        </block>
    </referenceContainer>

    <referenceBlock name="logo">
        <arguments>
            <argument name="logo_img_width" xsi:type="number">148</argument>
            <argument name="logo_img_height" xsi:type="number">43</argument>
        </arguments>
    </referenceBlock>
    <!--<referenceBlock name="header.panel" remove="true" />-->
    <move element="header.panel" destination="header-wrapper" after="logo"/>

    <referenceBlock name="header.panel.wrapper" remove="true"/>

    <move element="navigation.sections" destination="header-wrapper" after="logo"/>

    <!--<move element="top.search" destination="header-wrapper" after="-" />
    <move element="search" destination="header-wrapper" after="-" />
    <move element="catalog.compare.link" destination="header.links" />  -->

    <move element="top.search" destination="header.panel" after="header.links" />
    <move element="search" destination="header.panel" after="header.links" />
    <move element="catalog.compare.link" destination="header.links" />  
    <move element="minicart" destination="header.panel" after="header.links" />

    <referenceBlock name="catalog.compare.link" remove="true"/>

    <referenceBlock name="header" remove="true"/>
    <referenceBlock name="footer_links" remove="true"/>
    <referenceBlock name="form.subscribe" remove="true" />
    <referenceBlock name="copyright" remove="true"/>
    <referenceContainer name="footer">
        <block class="Magento\Cms\Block\Block" name="footerlinks">
            <arguments>
                <argument name="block_id" xsi:type="string">footerlinks</argument>
            </arguments>
        </block>
    </referenceContainer>
</layout>

Thanks for help !

4 Answers 4

0

As I see, this xml should not cause a blank page for search page, I doubt about another file ! Please try to add this to your theme:

app/design/frontend/{Vendor}/{theme}/Magento_Catalog-search/layout/catalogsearch_result_index.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<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>
        <attribute name="class" value="page-products"/>
        <referenceContainer name="content">
            <block class="Magento\CatalogSearch\Block\Result" name="search.result" template="Magento_CatalogSearch::result.phtml" cacheable="false">
                <block class="Magento\CatalogSearch\Block\SearchResult\ListProduct" name="search_result_list" template="Magento_Catalog::product/list.phtml" cacheable="false">
                    <arguments>
                        <!-- If argument's position depends on image size changeable in VDE:
                        positions:list-secondary,grid-secondary,list-actions,grid-actions,list-primary,grid-primary
                    -->
                        <argument name="positioned" xsi:type="string">positions:list-secondary</argument>
                    </arguments>
                    <block class="Magento\Catalog\Block\Product\ProductList\Toolbar" name="product_list_toolbar" template="Magento_Catalog::product/list/toolbar.phtml" cacheable="false">
                        <block class="Magento\Theme\Block\Html\Pager" name="product_list_toolbar_pager" cacheable="false"/>
                    </block>
                    <action method="setToolbarBlockName">
                        <argument name="name" xsi:type="string">product_list_toolbar</argument>
                    </action>
                    <block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers">
                        <block class="Magento\Framework\View\Element\Template" name="category.product.type.details.renderers.default" as="default"/>
                    </block>
                    <block class="Magento\Catalog\Block\Product\ProductList\Item\Container" name="catalogsearch.product.addto" as="addto">
                        <block class="Magento\Catalog\Block\Product\ProductList\Item\AddTo\Compare"
                               name="catalogsearch.product.addto.compare" as="compare"
                               template="Magento_Catalog::product/list/addto/compare.phtml"/>
                    </block>
                </block>
                <action method="setListOrders"/>
                <action method="setListModes"/>
                <action method="setListCollection"/>
            </block>
        </referenceContainer>
    </body>
</page>

Don't forget to clean your cache and deploying a static contents

php bin/magento cache:clean

php bin/magento setup:static-content:deploy -f

2
  • Thanks! I have copied file in p/design/frontend/{Vendor}/{theme}/Magento_Catalog-search/layout/catalogsearch_result_index.xml and p/design/frontend/{Vendor}/{theme}/Magento_Search/layout/catalogsearch_result_index.xml (and run shell comands) but page is still blank ...
    – matin
    Apr 15, 2018 at 6:45
  • If I remove file Magento_Theme/layout/default.xml search result page is shown (but my theme is not correct then of course)
    – matin
    Apr 15, 2018 at 6:46
0

I could solve it by copying original xml from Magento_Theme/layout/default.xml into my custom theme and remove tag

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceContainer name="header.panel">
        <block class="Magento\Framework\View\Element\Html\Links" name="header.links">
            <arguments>
                <argument name="css_class" xsi:type="string">header links</argument>
            </arguments>
        </block>
    </referenceContainer>
    <referenceBlock name="logo">
        <arguments>
            <argument name="logo_img_width" xsi:type="number">148</argument>
            <argument name="logo_img_height" xsi:type="number">43</argument>
        </arguments>
    </referenceBlock>
    <referenceContainer name="footer">
        <block class="Magento\Store\Block\Switcher" name="store_switcher" as="store_switcher" after="footer_links" template="Magento_Store::switch/stores.phtml"/>
    </referenceContainer>
    <referenceBlock name="report.bugs" remove="true"/>
    <move element="copyright" destination="before.body.end"/>

.....

0

You need to add below line in top of your themes "result.phtml" file at path app/design/frontend/{Vendor}/{Project}/Magento_CatalogSearch/templates/

$productList = $block->getProductListHtml();

So your file starting should look like below :

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile
$productList = $block->getProductListHtml();
?>
<?php if ($block->getResultCount()): ?>

0

Compare Theme and Vendor file default.xml what is the difference.

Or check the log files.

Your Answer

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

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