Magento的:文本框,而不是多分层导航选择 [英] Magento: textbox instead of multi select in layered navigation

查看:122
本文介绍了Magento的:文本框,而不是多分层导航选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有在Magento可能有一个多选属性,为此,我会用分层导航一个文本框,而不是显示从多选?

Is there a possibility in Magento to have a multi-select attribute, for which I would use a textbox in layered navigation instead of showing all items from multi-select?

我有一个属性,在那里我将有数以百计的选择和需要分层导航中使用它。

I have an attribute where I will have hundreds of options and need to use it in layered navigation.

当客户使用无效值,错误应该显示出来。

When customer uses invalid value, an error should show up.

编辑:从FlorinelChis后帮我曾经如下因素code在filter.phtml:

After the help from FlorinelChis I have folowing code in filter.phtml:

<ol>
<?php foreach ($this->getItems() as $_item): ?>
  <?php
  $attributeModel = $this->getAttributeModel();    
  $attribute_code =  $attributeModel->getAttributeCode();
  ?>
    <li>
      <?php if ($attribute_code != 'available_zip'): ?>
        <?php if ($_item->getCount() > 0): ?>
        <a href="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?></a>
        <?php else: echo $_item->getLabel() ?>
        <?php endif; ?>
        <?php if ($this->shouldDisplayProductCount()): ?>
        (<?php echo $_item->getCount() ?>)
        <?php endif; ?>
      <?php endif; ?>
    </li>
<?php endforeach ?>
</ol>
  <?php
    if ($attribute_code == 'available_zip'): 
          $cat =  Mage::registry('current_category')->getUrlPath() ;
          $url = Mage::getBaseUrl();
          /*$sendUrl = $this->urlEscape($_item->getUrl()).'+'.$url.$cat.'?'.$attribute_code.'='.$_item->getValue();*/
        echo '<form action="" method="get">';
        echo '<input type="text" size="5" maxlength="5" name="'.$attribute_code.'" />';
        echo '<button type="submit">OK</button>';
        echo '</form>';
  endif; ?>

我现在有一件事:
如何发送与id属性,而不是价值形态?

I have one more thing now: how to send the form with attribute id instead of value?

推荐答案

首先,让我们看看如何Magento显示左侧导航过滤器

First, let's find out how Magento displays the filters in left hand navigation

1)使模板路径提示:

1) Enable Template Path Hints:

和这里的结果是:

2)让我们来看看应用程序/设计/前端/基/默认/模板/目录/层/ filter.phtml (你应该在这个文件复制你主题文件夹结构)

2) Let's take a look at app/design/frontend/base/default/template/catalog/layer/filter.phtml (you should copy this file in your theme folder structure)

3)块($这个模板文件是一个扩展 Mage_Catalog_Block_Layer_Filter_Abstract

3) The block ($this in the template file is an instance of Mage_Catalog_Block_Layer_Filter_Attribute which extends Mage_Catalog_Block_Layer_Filter_Abstract)

4)你可以看到,在 Mage_Catalog_Block_Layer_Filter_Abstract A getName()方法的存在,所以你可以依靠这个功能,当你属性显示​​鉴别。别!标签可以改变你的code不会有用了。
回到我们的模板文件,可以得到attribute_ code(这是可靠的)

4) You can see that in Mage_Catalog_Block_Layer_Filter_Abstract a getName() method exists, so you could rely on this function to identify when you attribute is displayed. Don't! The label can change and your code won't be useful any more. Back to our template file, you can get the attribute_code (which is reliable)

//$this is instance of Mage_Catalog_Block_Layer_Filter_Attribute 
$attributeModel = $this->getAttributeModel();    
$attribute_code =  $attributeModel->getAttributeCode();

5)在您的模板,你可以有一个支票基于属性code,所以你要么显示标准列表或您的自定义HTML code与文本区域,而不是一个巨大的名单。

5) On your template you can have a check based on attribute code, so you display either the standard list or your custom html code with a textarea instead of a huge list.

这篇关于Magento的:文本框,而不是多分层导航选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆