Magento静态块现在显示在CMS页面中

Magento静态块现在显示在CMS页面中,magento,content-management-system,categories,display,Magento,Content Management System,Categories,Display,嘿!我正在尝试在cms页面上显示类别。我在网络上尝试了所有的解决方案,但没有一个对我有效。我最后试过的是这个 1.我在我的cms页面的内容选项卡中添加了此代码: {{block type=catalog/navigation template=catalog/category/list.phtml} 2.我已经创建了list.phtml,并将文件放在app/design/theme name/template/catalog/category上 这是我的文件的代码 <?php foreac

嘿!我正在尝试在cms页面上显示类别。我在网络上尝试了所有的解决方案,但没有一个对我有效。我最后试过的是这个

1.我在我的cms页面的内容选项卡中添加了此代码: {{block type=catalog/navigation template=catalog/category/list.phtml}

2.我已经创建了list.phtml,并将文件放在app/design/theme name/template/catalog/category上

这是我的文件的代码

<?php foreach ($this->getStoreCategories() as $_category): ?>
    <?php $open = $this->isCategoryActive($_category); ?>
    <?php
    $cur_category=Mage::getModel('catalog/category')->load($_category->getId());
    $layer = Mage::getSingleton('catalog/layer');
    $layer->setCurrentCategory($cur_category);
    if ($immagine = $this->getCurrentCategory()->getImageUrl()):
        ?>
        <div class="catalog-image">

            <div>
                <a href="<?php echo $this->getCategoryUrl($_category)?>">
                    <img src="<?php echo $immagine ?>" alt="<?php echo $this->htmlEscape($this->getCurrentCategory()->getName()) ?>" width="313" height="151" />
                </a>
            </div>

            <div class="left"><h2><a href="<?php echo $this->getCategoryUrl($_category)?>"><?php echo $_category->getName()?></a></h2></div>

        </div>
    <?php endif; ?>
<?php endforeach; ?>
我做错了什么?谢谢

在名为navigation的catalog下创建一个文件夹,并将list.phtml文件放在该文件夹中,它将起作用

{{block type=core/template=catalog/navigation/list.phtml category_id=507}

类别显示模式应在显示设置的静态块中

在cms页面的内容选项卡中添加此代码: {{block type=core/template=page/categories list.phtml}

在主题中创建一个文件,例如categories-list.phtml 路径:app/design/theme name/template/page/categories-list.phtml

在此文件中,编写以下代码以获取所有类别的集合:

<?php
$categories = Mage::getModel('catalog/category')
            ->getCollection()
            ->addAttributeToSelect('*')
            ->addIsActiveFilter();
?>
如果只需要某些类别的父级,请使用以下代码:

<?php
    $parent_category_id = 5;    // this is ID of parent category
    $categories = Mage::getModel('catalog/category')->getCategories($parent_category_id);
?>
要在屏幕上显示类别,请使用“循环”,查看以下内容:

<?php foreach ($categories as $category): ?>

    <p><?php echo $category->getImageUrl(); ?></p>
    <p><?php echo $category->getName(); ?></p>

<?php endforeach; ?>
如果使用父类别的类别显示图像,请使用以下代码:

<?php
    $parent_category_id = 5;    // this is ID of parent category
    $categories = Mage::getModel('catalog/category')->getCategories($parent_category_id);
?>
Mage::getModel'catalog/category'->load$category->getId->getImageUrl


您还没有在静态块中提供类别id。我按照您所说的做了,但不起作用。我的magento版本是1.9.2.2,我按照你说的做了,但不起作用。我的magento版本是1.9.2.2