1

I want to make 1 column layout for search result page when result not available.

How can i achieve this?

1

You can create a block rewriting the search results page say

Result.php

and in that

public function getNoResultText()
    {
        if ($this->catalogSearchData->isMinQueryLength()) {
            return __('Minimum Search query length is %1', $this->_getQuery()->getMinQueryLength());
        }

        return $this->getLayout()->getBlock('zero_res');
    }

Now create:-

Custom/Handles/view/frontend/layout/zero_res.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

<body>
    <referenceContainer name="content">
        <block class="Custom\Handles\Block\Result" name="zero_res" template="zero_res.phtml"/>
    </referenceContainer>
</body>

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.