Magento 2: How to call custom phtml file in another phtml file?
Replace below code with your block code
namespace Lapisbard\General\Block;
use Magento\Customer\Model\Session;
class CustomerAccount extends \Magento\Framework\View\Element\Template {
public function __construct(\Magento\Framework\View\Element\Template\Context $context,
Session $customerSession
)
{
parent::__construct($context);
$this->_customerSession = $customerSession;
}
public function isCustomerLoggedIn() {
return $this->_customerSession->isLoggedIn();
}
}
Then you can use it
echo $this->getLayout()->createBlock("Lapisbard\General\Block\CustomerAccount")->setTemplate("Lapisbard_General::customer_account.phtml")->toHtml();