drba1172 2012-10-29 16:01
浏览 17

Magento - 边栏类别过滤器,URL不是从root开始的

I have a single root category containing a single sub-category in my shop. It is set as an anchor to enable to dynamic attribute filters in my left hand column for navigation.

Whilst the filters render fine, and work flawlessly from the home page, when I navigate to a CMS page (or any page OTHER then the home page) the URLs are incorrect, e.g.

from home page:

http://www.domain.com/category_name.html?price=10-20

from the Contact Us page:

http://www.domain.com/contacts/category_name.html?price=10-20

As you see, its using the CMS page URL as the base path.

There are no settings for the filter URLs.

I am using the following code to display the filter sidebar navigation:

<?php if($this->canShowBlock()): ?>
<div class="product-range">
    <h2><?php echo $this->__('Browse Products') ?></h2>
    <?php echo $this->getStateHtml() ?>
    <?php if($this->canShowOptions()): ?>
            <?php $_filters = $this->getFilters() ?>
            <?php foreach ($_filters as $_filter): ?>
                <?php if($_filter->getItemsCount()): ?>
            <nav>
                <dl>
                    <dt><?php echo $this->__('Browse by '.$_filter->getName()); ?></dt>
                    <dd>
                        <?php echo str_replace(array('?','/?'), array('tapes.html?','/tapes.html?'), $_filter->getHtml()) ?>
                    </dd>
                </dl>
            </nav>
                <?php endif; ?>
            <?php endforeach; ?>
    <?php endif; ?>
</div>
<?php endif; ?>

"tapes.html" is the category URL (i only have the one category, this works fine!)

  • 写回答

1条回答 默认 最新

  • douxian3170 2012-10-29 21:23
    关注

    You should probably use slash for both replacements like this:

    <?php 
    
    echo str_replace(array('?','/?'), 
                     array('/tapes.html?','/tapes.html?'), 
                     $_filter->getHtml()) 
    
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用