-1

我为尝试修复它所做的一些事情

- 我尝试从 3columns.phtml 更改为我工作的那个 - 2columns-left.phtml,在许多不同的地方,但它已经说 2columns~。

- 多次尝试清除缓存。

- 在 cms 和 category 中也更改为此模板,但仍然无法正常工作。


我的第一页正在做我想做的事。但是,当我单击产品或任何 cms 页面时,徽标和标题看起来完全古怪,甚至缺少我在 header.phtml 中使用 div 添加的背景元素

有谁知道为什么会发生这种情况?:( 我应该在哪里改变一些东西?



从 2columns-left.phtml

<?php
/**
 * Template for Mage_Page_Block_Html
 */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
<head>
<?php echo $this->getChildHtml('head') ?>
</head>
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>
<?php echo $this->getChildHtml('after_body_start') ?>
<div class="wrapper">
    <?php echo $this->getChildHtml('global_notices') ?>
    <div class="page">
        <?php echo $this->getChildHtml('header') ?>
        <div class="main-container col2-left-layout">
            <div class="main">
                <?php echo $this->getChildHtml('breadcrumbs') ?>
                <div class="col-main">
                    <?php echo $this->getChildHtml('global_messages') ?>
                    <?php echo $this->getChildHtml('content') ?>
                </div>
                <div class="col-left sidebar"><?php echo $this->getChildHtml('left') ?></div>
            </div>
        </div>
        <?php echo $this->getChildHtml('footer') ?>
        <?php echo $this->getChildHtml('before_body_end') ?>
    </div>
</div>
<?php echo $this->getAbsoluteFooter() ?>
</body>
</html>



从 header.phtml

<?php
/**

/**
 * @var Mage_Page_Block_Html_Header $this
 */
?>
<div class="header-container">
    <div class="header">
        <?php if ($this->getIsHomePage()):?>
                <div class="header-menu">
        <p></p>
        <?php echo $this->getChildHtml('topMenu') ?>
        </div>
        <div class="header-bg">
        <h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
        <?php else:?>
        <a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a>
        <?php endif?>
        </div>

    </div>
    <div class="quick-access">
        <?php echo $this->getChildHtml('store_language') ?>
        <p class="welcome-msg"><?php echo $this->getWelcome()?></p>
        <?php echo $this->getChildHtml('topLinks') ?>
    </div>
    <?php echo $this->getChildHtml('topBar') ?>
    <?php echo $this->getChildHtml('topContainer'); ?>
</div>



这适用于第一页(索引/主页),但是当我点击周围的所有其他页面时 - 标题似乎不包含此代码(至少这是我的想法,因为它看起来不像它确实) :

            <div class="header-menu">
    <p></p>
    <?php echo $this->getChildHtml('topMenu') ?>
    </div>
    <div class="header-bg">
    <h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
    <?php else:?>
    <a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a>
    <?php endif?>
    </div>
4

2 回答 2

1

<?php if ($this->getIsHomePage()):?>检查主页是否处于活动状态的测试放错了位置,因此包装了太多代码:当当前页面不是主页时,一些标签没有关闭,菜单或标题背景不显示。

通常,这看起来像这样:

<?php if ($this->getIsHomePage()):?>
<h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
<?php else:?>
<a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a>
<?php endif?>
于 2012-07-13T07:30:48.080 回答
0

将您的代码移出 getIsHomePage()):?> 检查

<?php
/**

/**
 * @var Mage_Page_Block_Html_Header $this
 */
?>
<div class="header-container">
    <div class="header">
        <?php if ($this->getIsHomePage()):?>
                <div class="header-menu">
        <p></p>
        <?php echo $this->getChildHtml('topMenu') ?>
        </div>
        <div class="header-bg">
        <h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
        <?php else:?>
        <a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a>
        <?php endif?>
        </div>

    </div>
    <div class="quick-access">
        <?php echo $this->getChildHtml('store_language') ?>
        <p class="welcome-msg"><?php echo $this->getWelcome()?></p>
        <?php echo $this->getChildHtml('topLinks') ?>
    </div>
    <?php echo $this->getChildHtml('topBar') ?>
    <?php echo $this->getChildHtml('topContainer'); ?>
</div>

应该变成这样:

<?php
/**

/**
 * @var Mage_Page_Block_Html_Header $this
 */
?>
<div class="header-container">
    <div class="header">

        <div class="header-menu">
        <p></p>
        <?php echo $this->getChildHtml('topMenu') ?>
        </div>
        <div class="header-bg">
         <?php if ($this->getIsHomePage()):?>
        <h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
        <?php else:?>
        <a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a>
        <?php endif?>
        </div>

    </div>
    <div class="quick-access">
        <?php echo $this->getChildHtml('store_language') ?>
        <p class="welcome-msg"><?php echo $this->getWelcome()?></p>
        <?php echo $this->getChildHtml('topLinks') ?>
    </div>
    <?php echo $this->getChildHtml('topBar') ?>
    <?php echo $this->getChildHtml('topContainer'); ?>
</div>
于 2012-07-13T09:58:40.010 回答