【问题标题】:Magento adding new page layout for category useMagento 添加新的页面布局以供类别使用
【发布时间】:2013-03-05 11:39:07
【问题描述】:

我的商店中有一个类别需要与标准 Magento 布局完全不同的布局。因此,我创建了 1column.phtml 的新副本并对其进行了重新命名并进行了一个小改动以进行测试:

frontend/test/default/template/page/1column-lookbook.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="container">
    <?php echo $this->getChildHtml('global_notices') ?>
    <div class="page">
        <?php echo $this->getChildHtml('header') ?>
        <div class="page_content">
            <div class="row">
                <div class="sixcol">
                    <?php echo $this->getChildHtml('breadcrumbs') ?>
                </div>
                <div class="sixcol last">

                </div>
            </div>
            <div class="row"><h3>Filter here</h3></div>
            <div class="row"><h3>Scrolling content</h3></div>
            <div class="row">
                <div class="main-content">
                    <?php echo $this->getChildHtml('global_messages') ?>
                    <?php echo $this->getChildHtml('content') ?>
                </div>
            </div>
            <?php echo $this->getChildHtml('footer') ?>
            <?php echo $this->getChildHtml('before_body_end') ?>
        </div>
    </div>
</div>
<?php echo $this->getAbsoluteFooter() ?>
</body>
</html>

但是,我似乎无法让我的类别看到它,我尝试在 page.xml 和 layout.xml 文件中添加对它的引用。但无论我尝试了什么,我似乎都无法让它显示在我的类别的页面布局下拉列表中。

【问题讨论】:

    标签: xml magento-1.7


    【解决方案1】:

    当您在 magento 中搜索“1column.phtml”字符串时,您会发现:

    App/code/core/Mage/Page/etc/config.xml
    在第 45 行,您会找到所需的配置

    现在您可以将相同的配置结构放入您自己的模块中,如下所示:

    <global>
        <page>
            <layouts>
                <test module="page" translate="label">
                    <label>The test</label>
                    <template>page/test.phtml</template>
                    <layout_handle>page_test</layout_handle>
                </test>
            </layouts>
        </page>
    </global>
    

    刷新magento缓存并转到您的类别编辑屏幕=>自定义设计=>页面布局并选择您刚刚在下拉列表中添加的模板。

    希望这会有所帮助。

    【讨论】:

      【解决方案2】:

      Magento Module for new CMS layout, but in version 1.7.0.2

      http://www.magentocommerce.com/boards/viewthread/285425/#t400446

      这方面有很多..

      在您的自定义模块 XML 配置中添加一些条目以添加您的新布局

      <config>
          <modules>
              <My_Module>
                  <version>0.0.0.1</version>
              </My_Module>
          </modules>
          <global>
          <page>
              <layouts>
                  <my_layout module="page" translate="label">
                      <label>My Layout</label>
                      <template>page/mylayout.phtml</template>
                      <layout_handle>my_layout</layout_handle>
                  </my_layout>
              ....
      

      之后别忘了刷新缓存

      【讨论】:

      • 这两个都是专门用于 CMS 页面的,那是否也添加了可供类别使用的内容?
      【解决方案3】:

      查找:/App/etc/local.xml

      &lt;/global&gt;标签之前,放置额外的页面布局配置。

      <page>
        <layouts>
          <lookbook module="page" translate="label">
            <label>LOOK BOOK</label>
              <template>page/1column-lookbook.phtml</template>
            <layout_handle>page_lookbook</layout_handle>
          </lookbook>
        </layouts>
      </page>
      

      就是这样。 :)

      【讨论】:

      • 如何在magento中添加多个自定义布局?
      【解决方案4】:

      创建新布局的更好方法。

      http://www.sundataplus.com/adding-a-new-page-layout-to-magento-1-x/

      文件可以编辑:app/code/core/Mage/Page/etc/config.xml 在 .. 之间添加新行以及其他布局。

      <page>
              <layouts>
      .
      .
              <home module="page" translate="label">
                  <label>Home</label>
                  <template>page/home.phtml</template>
                  <layout_handle>page_home</layout_handle>
              </home>
      .
      .
              </layouts>
      </page>
      

      创建新文件:template/page/home.phtml 以及 1column.phtml、2columns-left.phtml 等。您可以复制 home.phtml 中的列布局 phtml 之一的现有代码。根据需要修改 home.phtml 中的代码。

      【讨论】:

        猜你喜欢
        • 2014-08-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-09
        • 2019-03-14
        • 1970-01-01
        相关资源
        最近更新 更多