我創建了一個多選項屬性,以便爲每個選項顯示圖像,但我無法使其工作。屬性將圖像分配給每個多選項
我已經從這裏的另一篇文章中使用此代碼來獲取要顯示的選項列表。
我使用的代碼是:
<?php if($_product->getResource()->getAttribute('suitable_for')->getFrontend()->getValue($_product)): ?>
<h4>Suitable for:</h4>
<ul><li><?php
$_comma = ",";
$_list = "</li><li>";
echo str_replace($_comma,$_list,$_product->getResource()->getAttribute('suitable_for')->getFrontend()->getValue($_product)) ?>
</li></ul>
<?php endif; ?>
所以這個現在顯示的選項,對彼此頂部一個列表。
正如我所說我想要爲每個選項顯示圖像。
我認爲最好的辦法是有div和分配給每個div的圖像。
我希望我能得到的輸出是:
<div class="option1"></div>
<div class="option2"></div>
<div class="option3"></div>
<div class="option3"></div>
,而不是輸出,上面的代碼有:
<ul>
<li>option1</li>
<li>option2</li>
<li>option3</li>
<li>option4</li>
</ul>
你只是問如何將輸出從無序列表更改爲一組DIV元素? – beeplogic