【问题标题】:Fishpig Wordpress Extension for Magento Category HierarchyMagento 类别层次结构的 Fishpig Wordpress 扩展
【发布时间】:2014-09-27 09:41:12
【问题描述】:

我正在开发一个使用 Fishpig Wordpress 扩展的 Magento 网站。我们在左侧边栏中显示了 Categories 小部件,它被设置为显示层次结构。

它的工作深度为两层(即 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; ?>

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

【问题讨论】:

    标签: php wordpress magento hierarchy fishpig


    【解决方案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; ?>
    

    【讨论】:

      猜你喜欢
      • 2012-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-06
      • 2016-08-26
      • 1970-01-01
      • 2014-07-29
      相关资源
      最近更新 更多