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

时间:2014-09-27 09:41:12

标签: php wordpress magento hierarchy fishpig

我正在使用Fishpig Wordpress Extension的Magento网站上工作。我们在左侧边栏中显示了“类别”窗口小部件。它被设置为显示层次结构。

enter image description here

它正在深入两个级别(即.level0.level1的ul& li&#;;但是没有显示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; ?>

有没有办法在Fishpig的Magento上显示两个以上的wordpress类别?

1 个答案:

答案 0 :(得分:1)

我更新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; ?>