如何在标题magento 2中添加广告图片

时间:2016-10-17 07:38:31

标签: magento magento2 magento2.0.2 magento-2.0.7

如何在标题320x72(heightxwidth)中添加图像在magento 2.页眉和页脚文件中并在app-> design-> frontend->中显示或者shopping \ vendor \ magento \ theme-frontend-blank \ Magento_Theme \ layout。建议我一步一步地改变。

1 个答案:

答案 0 :(得分:0)

步骤1.在Magento 2中创建新主题,如下面的目录

app / design / frontend / / / Magento_Theme / templates / html

步骤2.从vendor \ magento \ module-theme \ view \ frontend \ templates \ html复制header.phtml文件并粘贴到app / design / frontend / / / Magento_Theme / templates / html

步骤3.现在您可以更改header.phtml文件。

    Image can add in header by below code.

<?php 
        $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();  

        $storeManager = $_objectManager->get('Magento\Store\Model\StoreManagerInterface'); 

        $currentStore = $storeManager->getStore();

        $mediaUrl = $currentStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); 
    ?>

    <img scr="<?php echo $mediaUrl.'/image.jpg' ?>">