Magento,布局在所有页面上看起来都不一样

时间:2012-07-13 02:14:18

标签: php templates magento layout

我尝试修复它的一些事情

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

  - 多次尝试清理缓存。

  - 也在cms和类别中更改为此模板,但仍然没有    工作。


我的第一页正在做我想做的事。但是当我点击产品或任何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>

2 个答案:

答案 0 :(得分: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?>

答案 1 :(得分:0)

将您的代码移到getIsHomePage()之外:?&gt;检查

<?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>