繁体   English   中英

用于Magento类别层次结构的Fishpig Wordpress扩展

[英]Fishpig Wordpress Extension for Magento Category Hierarchy

我正在使用Fishpig Wordpress Extension的Magento网站上工作。 我们在左侧边栏中显示了类别小部件,并将其设置为显示层次结构。

在此处输入图片说明

它的工作深度为两个级别(即ul&li与.level0.level1 ),但未显示类别3的深度,即level2

我已经在基本的wordpress安装上对此进行了测试,我可以将其显示为3级,但是我无法通过fishpig WordPress集成使其在Magento上运行。 我已将帖子分配给所有子类别。

我在template/wordpress/sidebar/widget/categories.phtml看到,此代码块用于获取level1子类别:

<?php else: ?>
        <?php foreach($categories as $category): ?>
            <li class="level0 item<?php if ($this->isCurrentCategory($category)): ?> active<?php endif; ?>">
                <a  class="level0" href="<?php echo $category->getUrl() ?>" title="<?php echo $category->getName() ?>">
                    <?php echo $category->getName() ?>
                </a><?php if ($this->getCount()): ?> (<?php echo $category->getPostCount() ?>)<?php endif; ?>
                <?php if ($this->getHierarchical()): ?>
                    <?php $children = $children = $category->getChildrenCategories() ?>
                    <?php if (count($children) > 0): ?>
                        <ul class="level1">
                            <?php foreach($children as $child): ?>
                                <?php if ($child->getPostCount() > 0): ?>
                                <li class="level1 item<?php if ($this->isCurrentCategory($child)): ?> active<?php endif; ?>">
                                    &raquo; <a href="<?php echo $child->getUrl() ?>" title="<?php echo $child->getName() ?>" class="level1"><?php echo $child->getName() ?></a><?php if ($this->getCount()): ?> (<?php echo $child->getPostCount() ?>)<?php endif; ?>
                                </li>
                                <?php endif; ?>
                            <?php endforeach; ?>
                        </ul>
                    <?php endif; ?>
                <?php endif; ?>
            </li>
        <?php endforeach; ?>
    <?php endif; ?>

有什么方法可以在Magento和Fishpig上显示两个以上级别的wordpress类别?

我更新了template/wordpress/sidebar/widget/categories.phtml使其包含第3级,并且可以正常工作:)

<?php foreach($categories as $category): ?>
    <li class="level0 item<?php if ($this->isCurrentCategory($category)): ?> active<?php endif; ?>">
        <a  class="level0" href="<?php echo $category->getUrl() ?>" title="<?php echo $category->getName() ?>">
            <?php echo $category->getName() ?>
        </a><?php if ($this->getCount()): ?> (<?php echo $category->getPostCount() ?>)<?php endif; ?>
        <?php if ($this->getHierarchical()): ?>
            <?php $children = $children = $category->getChildrenCategories() ?>
            <?php if (count($children) > 0): ?>
                <ul class="level1">
                    <?php foreach($children as $child): ?>
                        <?php if ($child->getPostCount() > 0): ?>
                        <li class="level1 item<?php if ($this->isCurrentCategory($child)): ?> active<?php endif; ?>">
                            &raquo; <a href="<?php echo $child->getUrl() ?>" title="<?php echo $child->getName() ?>" class="level1"><?php echo $child->getName() ?></a><?php if ($this->getCount()): ?> (<?php echo $child->getPostCount() ?>)<?php endif; ?>
                                      <?php $children2 = $children2 = $child->getChildrenCategories() ?>
                                      <?php if (count($children2) > 0): ?>
                                          <ul class="level2">
                                              <?php foreach($children2 as $child2): ?>
                                                  <?php if ($child2->getPostCount() > 0): ?>
                                                      <li class="level12 item<?php if ($this->isCurrentCategory($child2)): ?> active<?php endif; ?>">
                                                          &raquo; <a href="<?php echo $child2->getUrl() ?>" title="<?php echo $child2->getName() ?>" class="level1"><?php echo $child2->getName() ?></a><?php if ($this->getCount()): ?> (<?php echo $child2->getPostCount() ?>)<?php endif; ?>
                                                      </li>
                                                  <?php endif; ?>
                                              <?php endforeach; ?>
                                          </ul>
                                      <?php endif; ?>
                        </li>
                        <?php endif; ?>
                    <?php endforeach; ?>
                </ul>
            <?php endif; ?>
        <?php endif; ?>
    </li>
<?php endforeach; ?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM