在标签图像中插入自定义/动态URL

问题描述 投票:0回答:1

我在文件image_with_border.phtml中有此代码。我希望能够在URL后面添加sku代码。

     <?php
    /**
  * Copyright © Magento, Inc. All rights reserved.
   * See COPYING.txt for license details.
    */
    ?>
      <?php /** @var $block \Magento\Catalog\Block\Product\Image */ ?>

     <span class="product-image-container"
  style="width:<?= /* @escapeNotVerified */ $block->getWidth() ?>px;">
<span class="product-image-wrapper"
      style="padding-bottom: <?= /* @escapeNotVerified */      ($block->getRatio() * 100) ?>%;">
    <img class="product-image-photo"
        <?= /* @escapeNotVerified */ $block->getCustomAttributes() ?>
        src="www.nuovo.it/"<? here would insert Sku code ?>
        max-width="<?= /* @escapeNotVerified */ $block->getWidth() ?>"
        max-height="<?= /* @escapeNotVerified */ $block->getHeight() ?>"
        alt="<?= /* @escapeNotVerified */ $block->stripTags($block->getLabel(), null, true) ?>"/></span>
      </span>
php html oop concatenation magento-2.3
1个回答
0
投票

首先为您的BASE链接创建一个变量。

$link="https://www.nuovo.it/";


然后获取SKU代码并通过strtolower函数(通常将所有内容保持在较低水平,但无需执行下一步)是一个好习惯,] >>。我不知道如何您将在此处获取SKU代码,因此例如,可以随意更改strtolower( )添加的帖子的内部。

$sku=strtolower($_POST['SKUCODE']);

只需将其与$link变量连接

$newlink=$link.$sku;

使用$newlink中的src变量>>

src="<?php echo "$newlink" ?>"

© www.soinside.com 2019 - 2024. All rights reserved.