Magento集成了过滤器

时间:2014-09-23 12:59:25

标签: magento filter

我想整合和编辑过滤器功能。

我有这段代码:

<?php $_filters = $this->getFilters() ?>
        <?php foreach ($_filters as $_filter): ?>
            <?php if($_filter->getItemsCount()): ?>
                <div class="option-combo <?php echo $this->__($_filter->getName()) ?>">         
                    <ul class="filter option-set clearfix " data-filter-group="<?php echo $this->__($_filter->getName()) ?>">
                        <li><h4><?php echo $this->__($_filter->getName() ) ?> : </h4></li>
                        <li><a href="#filter-<?php echo $this->__($_filter->getName()) ?>-any" data-filter-value="" class="selected">All</a></li>

                            <?php echo $_filter->getHtml() ?>                                                                   
                    </ul>
                </div>      

            <?php endif; ?>
        <?php endforeach; ?>>

它有效,但我不想调用另一个extern phtml文件(filter.phtml,来自$ _filter-&gt; getHtml())但是当我将filter.phtml中的代码直接复制到我的主页面时,像这样:

<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
    <?php if($_filter->getItemsCount()): ?>
        <div class="option-combo <?php echo $this->__($_filter->getName()) ?>">         
            <ul class="filter option-set clearfix " data-filter-group="<?php echo $this->__($_filter->getName()) ?>">
                <li><h4><?php echo $this->__($_filter->getName() ) ?> : </h4></li>
                <li><a href="#filter-<?php echo $this->__($_filter->getName()) ?>-any" data-filter-value="" class="selected">All</a></li>

                    <!-- I want to remove this external call and paste directly the content in it -->
                    <?php //echo $_filter->getHtml() ?>

                    <?php foreach ($this->getItems() as $_item): ?>

                        <?php if ($_item->getCount() > 0): ?>

                            <?php $Clean = $_item->getLabel();      ?>                                                              
                            <li style="display:none"><a href="#filter-<?php echo $_item->getLabel() ?>-<?php echo $Clean ?>" data-filter-value=".<?php echo $Clean ?>"><?php echo $_item->getLabel() ?></a></li>
                            <li><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; ?>
                    </li>
                <?php endforeach ?>
            </ul>
        </div>
    <?php endif; ?>
<?php endforeach; ?>

它没有显示任何结果......并且没有错误!

1 个答案:

答案 0 :(得分:0)

您可以尝试以下代码: -

   <?php $_filters = $this->getFilters() ?>
            <?php foreach ($_filters as $_filter): ?>
            <?php if($_filter->getItemsCount()): ?>
                <dt><?php echo $this->__($_filter->getName()) ?></dt>
                <dd><?php echo $_filter->getHtml() ?></dd>
             <?php else:?>
                // here you can add own code
            <?php endif; ?>
            <?php endforeach; ?>