below the account navigation is there an easy way for a newbie to add an image pointing to a page in the magento2? This account navigation appears on the side of my account dashboard. thanks!
1 Answer
For the add image and there link in the below myaccount navigation dashboard.
Follow below steps.
File path: magento/app/design/frontend/Namespace/theme/Magento_Customer/layout/customer_account.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Customer My Account (All Pages)" design_abstraction="custom">
<body>
<block class="Magento\Framework\View\Element\Template" name="new-sidebar-image-block" template="Magento_Customer::imageblock.phtml"/>
</body>
</page>
File path: magento/app/design/frontend/Namespace/theme/Magento_Customer/templates/imageblock.phtml
<a href="<?php echo $block->getUrl()?>customer/account/" target="_self"><img src="<?php echo $block->getUrl("pub/media/myaccount/")?>image.png"/></a>
Put your image to below path:
pub/media/myaccount/image.png
Now run the command php bin/magento cache:flush
Check in myaccount image will appear.
Hope it help.
-
thanks. I'm curios about the path,
magento/app/design/frontend/Namespace/theme/Magento_Customer/layout/customer_account.xml
. I'm currently using template monster from a vendor so would this still work or should I find my templates customer_account.xml instead?– AhdeeCommented Jun 28, 2019 at 15:14 -
-
-
so I tried this but its not working. Currently I have two subfolders below /app/design/frontend they are Magento and templatemonster. I tried two ways, first I made a seperate folder called test and put
./test/Magento_Customer/layout/customer_account.xml
but that did not work so I tried putting it under the subfolder magento but did not work as well. Any other place I should try?– AhdeeCommented Jul 5, 2019 at 0:02 -
You have to need place the customer_account.xml in your theme below path. app/design/frontend/templatemonster/yourtheme/Magento_Customer/layout/customer_account.xml Commented Jul 5, 2019 at 4:37