I want to create a new custom Block and Block phtml file same as the Customer Index Block
for use by the customer, when the customer login the customer just clicks on the left navigation link and access the phtml file.
I have added the custom link already in the below XML file:
app\design\frontend\Vendor\Theme\Magento_Customer\layout/customer_account.xml
<block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-account-myinformation-link">
<arguments>
<argument name="label" xsi:type="string" translate="true">my information</argument>
<argument name="path" xsi:type="string">customer/account/myinformation</argument>
</arguments>
</block>
After clicking on this link, I want to call Block to get customer data like email, name mobile, address, etc.
Please help me if anyone has created the Custom Block and Custom phtml file in the Magento_Customer module.
Best Answer
Create a Module Namspace/Customer
Create xml view/frontend/layout/customer_account_myinformation.xml
Create phtml file view/frontend/templates/account/myinformation.phtml
Create Controller Controller/Account/MyInformation.php
create Block Block\Account\MyInformation.php
create routes.xml etc/frontend/routes.xml
Hope it will help you. Please vote us if you like our answer.