Commit 70c39dc0 by wd

修改轮播图片media地址

parent 8971e19a
...@@ -4,6 +4,12 @@ $collection = $block->getCollection(); ...@@ -4,6 +4,12 @@ $collection = $block->getCollection();
?> ?>
<div class="banner1" style="background-color: #f0f0f0;"></div> <div class="banner1" style="background-color: #f0f0f0;"></div>
<?php
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); //instance of\Magento\Framework\App\ObjectManager
$storeManager = $_objectManager->get('Magento\Store\Model\StoreManagerInterface');
$currentStore = $storeManager->getStore();
$mediaUrl = $currentStore -> getBaseUrl ( \Magento\Framework\UrlInterface :: URL_TYPE_MEDIA ) ;
?>
<?php foreach ($collection->getItems() as $item):?> <?php foreach ($collection->getItems() as $item):?>
<?php echo $item->getData('name');?> <?php echo $item->getData('name');?>
...@@ -16,8 +22,8 @@ require(['jquery','banner'],function ($){ ...@@ -16,8 +22,8 @@ require(['jquery','banner'],function ($){
[ [
<?php foreach ($collection->getItems() as $item):?> <?php foreach ($collection->getItems() as $item):?>
[ [
<?php echo "'/media/" . $item->getData('img_patch') . "',";?> <?php echo "'".$mediaUrl . $item->getData('img_patch') . "',";?>
<?php echo "'/media/" . $item->getData('phone_img_patch') . "',";?> <?php echo "'".$mediaUrl . $item->getData('phone_img_patch') . "',";?>
], ],
<?php endforeach;?> <?php endforeach;?>
]; ];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment