【问题标题】:Hide frontview specific attribute when empty value on custom attribute value当自定义属性值为空时隐藏前视图特定属性
【发布时间】:2019-10-27 21:33:21
【问题描述】:

我创建了自定义属性值来连接产品视图上的外部链接显示。我的自定义属性作为连接到我的公共市场商店(如 lazada)的按钮。问题是当后端没有值时如何隐藏属性。

属性值“shoopee”是我的代码

<button type="button" onclick="window.open('','_new').location.href = '<?php echo $_helper->productAttribute($_product, $_product->getshopee(), 'shopee') ?>'; return false;" class="button" role="button"><span><span><?php echo $this->__('beli shopee') ?></span></span></button>

当属性值为空时,我想隐藏按钮。

【问题讨论】:

  • 把按钮放到PHP里面,就是不回显,productAttribute什么都不返回,问题出在哪里?
  • 顺便说一句:我不知道你的 $_helper 返回什么,是 FALSE 还是空的,当后端没有价值时?

标签: php html magento attributes magento-1.9


【解决方案1】:

尝试类似:

<?php if ($_helper->productAttribute($_product, $_product->getshopee(), 'shopee')) : ?>
<button type="button" onclick="window.open('','_new').location.href = '<?php echo $_helper->productAttribute($_product, $_product->getshopee(), 'shopee') ?>'; return false;" class="button" role="button"><span><span><?php echo $this->__('beli shopee') ?></span></span></button>
<?php endif; ?>

【讨论】:

    猜你喜欢
    • 2021-04-23
    • 1970-01-01
    • 1970-01-01
    • 2016-10-06
    • 1970-01-01
    • 1970-01-01
    • 2011-11-10
    • 1970-01-01
    • 2016-09-05
    相关资源
    最近更新 更多