0

我有一个问题,以前以某种方式在这里发布过,但从来没有针对这种情况。通常此错误发生在 App.php 中,但对我来说,它发生在第 42 行的 /httpdocs/app/design/frontend/default/theme/template/catalog/category/view.phtml 中,我已在下面指出。

有没有人对此有任何想法?我有点不知所措。

    <?php
    /**
     * Category view template
     *
     * @see Mage_Catalog_Block_Category_View
     */
    ?>
    <?php
    $_helper    = $this->helper('catalog/output');
    $_category  = $this->getCurrentCategory();
    $_imgHtml   = '';

    $_category->setCanShowBlock(false);
    $_category->setHasHeaderImage(false);
    //////Line 42///////    if (get_class($this->getLayout()->getBlock('catalog.leftnav')) != 'Mage_Catalog_Block_Navigation') {
        $_category->setCanShowBlock($this->getLayout()->getBlock('mana.catalog.leftnav')->canShowBlock());
    }

    if ($_imgUrl = $_category->getImageUrl()) {
        $_imgHtml = '<img src="'.$_imgUrl.'" alt="'.$this->htmlEscape($_category->getName()).'" title="'.$this->htmlEscape($_category->getName()).'" />';
        $_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
        $_category->setHasHeaderImage(true);
    }
?>

<?php /*

<!-- <div class="page-title category-title">
    <?php if($this->IsRssCatalogEnable() && $this->IsTopCategory()): ?>
        <a href="<?php echo $this->getRssLink() ?>" class="link-rss"><?php echo $this->__('Subscribe to RSS Feed') ?></a>
    <?php endif; ?>
    <h1><img src="<?php echo $this->getSkinUrl('images/' . $_helper->categoryAttribute($_category, $_category->getName(), 'name') . '.jpg') ?>" alt="<?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?>" /></h1>
</div> -->

*/ 

Mage::getModel('core/session')->setHasAdditionalDescription(false);
?>

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>

<div id="category_top_image"<?php if ($_category->getCanShowBlock()): ?> style="margin-left: -280px;"<?php endif ?>>

<?php if($_imgUrl): ?>
    <?php echo $_imgHtml ?>
<?php endif; ?>

<?php if(strtolower($_category->getHideTitle()) != 'yes'): ?>
<h1><?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?></h1>
<?php endif ?>

<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
    <div class="category-description std">
        <?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?>
    </div>
<?php endif; ?>

</div>

<?php if($this->isContentMode()): ?>
    <?php echo $this->getCmsBlockHtml() ?>

<?php elseif($this->isMixedMode()): ?>
    <?php echo $this->getCmsBlockHtml() ?>
        <?php if($_description=$this->getCurrentCategory()->getAdditionalDescription()): ?>
            <?php Mage::getModel('core/session')->setHasAdditionalDescription(true) ?>
<div class="category-additional-description std">
            <?php echo $_helper->categoryAttribute($_category, $_description, 'additional_description') ?>
</div>
        <?php endif; ?>    
    <?php echo $this->getProductListHtml() ?>

<?php else: ?>
    <?php if($_description=$this->getCurrentCategory()->getAdditionalDescription()): ?>
            <?php Mage::getModel('core/session')->setHasAdditionalDescription(true) ?>
<div class="category-additional-description std">
        <?php echo $_helper->categoryAttribute($_category, $_description, 'additional_description') ?>
</div>
    <?php endif; ?>
    <?php echo $this->getProductListHtml() ?>
<?php endif; ?>
4

1 回答 1

2

嗯,这个错误意味着页面上没有名为catalog.leftnav的块,所以你应该检查你的布局。实际上这种检查类的方式很糟糕,因为它会导致这样的错误。还有一个问题,如果某些扩展会重写 Mage_Catalog_Block_Navigation 类。

所以我不确定你为什么要检查那个块的类,但如果你真的需要它,我会建议一些风险较小且重写友好的东西:

if ($block = $this->getLayout()->getBlock('catalog.leftnav') && $block instanceof Mage_Catalog_Block_Navigation) {
    ...
}
于 2013-05-27T10:27:00.417 回答