0
$listBusBlock = $listOfBuses->getLayout()->createBlock('Imonn\Bookings\Block\Buslist')->setTemplate('Imonn_Bookings::Busbooking/listOfBusses.phtml')->toHtml();
$this->getResponse()->setBody($listBusBlock);

in the above PHP code, I want to add $listBusBlock between the header and footer.

If I use $this->getResponse()->setBody($listBusBlock); the content is set to the entire body and the header and footer are gone. what should I use instead of setBody so that the content can be added between the header and footer.

1

Try with below snippets:

$listBusBlock = $listOfBuses->getLayout()->createBlock('Imonn\Bookings\Block\Buslist')->setTemplate('Imonn_Bookings::Busbooking/listOfBusses.phtml')->toHtml();
$this->getLayout()->getBlock('content')->append($listBusBlock);
0

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.