How to call custom block in phtml file

<?php echo $block->getLayout()
    ->createBlock('Codism\Csr\Block\Index\TopMenu')
    ->setTemplate('Codism_Csr::menu.phtml')
    ->toHtml();
?>
 OR
<?php echo $this->getLayout()
    ->createBlock('Codism\Csr\Block\Index\TopMenu')
    ->setTemplate('Codism_Csr::menu.phtml')
    ->toHtml();
?>

Leave a comment

Your email address will not be published. Required fields are marked *