0

Fishpig Wordpress Extension を使用している Magento サイトで作業しています。左側のサイドバーにカテゴリ ウィジェットが表示され、階層を表示するように設定されています。

ここに画像の説明を入力

2 レベルの深さで動作しています (つまり、 & を使用した ul & li .level0).level1が、3 レベルの深さのカテゴリを表示していません。つまりlevel2

基本的なワードプレスのインストールでこれをテストしましたが、カテゴリを 3 レベル下に表示することはできますが、fishpig WordPress 統合を使用して Magento で動作させることはできません。すべてのサブカテゴリに投稿を割り当てました。

template/wordpress/sidebar/widget/categories.phtmllevel1 の子カテゴリを取得するためのこのコード ブロックがあることがわかります。

<?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 で 2 レベル以上のワードプレス カテゴリを表示する方法はありますか?

4

1 に答える 1

1

template/wordpress/sidebar/widget/categories.phtml3番目のレベルを含めるように更新しましたが、うまくいきました:)

<?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; ?>
于 2014-09-27T11:17:56.297 に答える