English 中文(简体)
Magento: 以独有的 ID s 列表显示多选择列表, 这样列表项目可以更改为使用 CSS 的图像
原标题:Magento: display multi-selection as a list with unique ID s so list item can be changed to an image using CSS
  • 时间:2012-05-22 14:33:31
  •  标签:
  • magento

我找到了如何用列表来显示我自定义的多选择 attractie 列表, 但还没有找到如何在列表项目中添加 ID 或类 。 这将允许我使用 CSS 而不是文本来显示图像 。

顺便说一句,这是我用来 显示我的习惯属性"评级" 列表的代码:

        <?php if($_product->getResource()->getAttribute( rating )->getFrontend()->getValue($_product)): ?>
        <ul><li><?php
        $_comma = ",";
        $_list = "</li><li>";
        echo str_replace($_comma,$_list,$_product->getResource()->getAttribute( rating )->getFrontend()->getValue($_product))    ?>    
        </li></ul>
        <?php endif; ?> 
        </div>
问题回答

在不知道您函数返回的确切格式的情况下, 我无法100%确定, 但我觉得这能解决问题:

    <div>
    <?php if($_product->getResource()->getAttribute( rating )->getFrontend()->getValue($_product)):?>
        <ul>
        <?php $i=0?>
        <?php foreach(explode( , , $_product->getResource()->getAttribute( rating )->getFrontend()->getValue($_product)) as $value) : ?>
            <li id="value_<?php echo $i?>"><?php echo $value ?></li>
            <?php $i++ ?>
        <?php endforeach ?>
        </ul>
    <?php endif; ?> 
    </div>

只需修改返回时间, 就可以让您返回一个阵列, 但是如果返回时间是逗号分隔列表, 且不易更改, 那么爆炸就应该做这个把戏 。





相关问题
Magento addFieldToFilter allow NULLs

When using the Magento collection method addFieldToFilter is it possible to allow filtering by NULL values? I want to select all the products in a collection that have a custom attribute even if no ...

Get product link from Magento API

I am new to Magento and using their API. I need to be able to get the product url from the API call. I see that I can access the url_key and url_path, but unfortunately that s not necessarily what ...

magento extension installation

I want to install a Magento extension in WAMP, but not from the Magento connect system. How can I do this? I have the module (extension) code and I already installed the sample data in the Magento ...

Link to a specific step in onepage checkout

Is it possible to redirect the browser to nth step in the onepage checkout? If so, how would one go about doing it? I m working on a payment module and have a sort of "cancel" action that i would ...

How do I filter a collection by a YesNo type attribute?

I have a ‘featured’ attribute, which has a Yes/No select-list as the admin input. I presume that the values for Yes and No are 1 and 0, as they are for every other Yes/No list. However, if I try and ...

热门标签