1

我以前问过这个问题并得到了一些答复,但不明白。这是我的 1column.phtml 的内容:

<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">
        <div class="col-outer-left outer-sidebar">
          <?php echo $this->getChildHtml('outer-left') ?>
        </div>
        <div class="main-container col1-layout">
          <?php echo $this->getChildHtml('header') ?>
          <div class="main">
            <?php echo $this->getChildHtml('breadcrumbs') ?>
            <?php echo $this->getChildHtml('global_messages') ?>
            <div class="col-main">
              <?php echo $this->getChildHtml('content') ?>
            </div>
          </div>
          <?php echo $this->getChildHtml('footer') ?>
          <?php echo $this->getChildHtml('before_body_end') ?>
        </div>
        <div class="col-outer-right outer-sidebar">
          <?php echo $this->getChildHtml('outer-right') ?>
        </div>
      </div>
    </div>
    <?php echo $this->getAbsoluteFooter() ?>
  </body>
</html>

这是我想要的布局。中心部分将是固定宽度。但是左外和右外是可变宽度的,我想偶尔在那里放东西。但是,我不知道如何填充它们。当 $this->getChildHtml('outer-right') 被调用时,它是从 PHP 中获取的吗?我已经组成了这个右外字符串,因为这是一列的布局,三列页面的布局也有这些额外的外部部分(使设计几乎像 5 列)。

在 app/design/frontend/default/layout/cms.xml 里面我找到了这一行:

<cms_index_index translate="label">
    <label>CMS Home Page</label>
</cms_index_index>

有人建议我替换这条线。我不明白这个 cms_inde_index 代码是从哪里调用的。我什至不知道如何在源代码中搜索 cms_index_index 的外观。

请帮助我了解磁电机。我真的被困住了。


注意:我希望主页使用 1column.phtml 并在左外部分显示一些内容,而其他一些 1column.phtml 在右列中显示其他内容。我如何实现这一目标?

注意:在 CMS -> 页面下,我可以在 1 列、2 列左、2 列右、3 列或空之间进行选择。我在想,在我的情况下,如果我无法以更简单的方式完成我所追求的目标,我什至可能不得不添加到这个列表中,但是我在文档中找不到如何增加这个列表的任何地方,也找不到这些之间的映射找到名称和相应的 phtml 文件。


好的,所以我将以下文件添加到我的设计包主题的布局目录中:

File: local.xml
Contents:
<?xml version="1.0"?>
<layout version="0.1.0">
  <cms_index_index>
    <reference name="root">
      <block type="core/template" name="outer-right" template="page/outer-right.phtml" />
    </reference>
  </cms_index_index>
</layout>

这成功地将 outer-right.phtml 模板的输出添加到正确的位置,但仅在查看主页时。我现在希望将其与所有页面一起输出,包括具有布局的页面:

1column.phtml 2columns-right.phtml 2columns-left.phtml 3columns.phtml

我该怎么做呢?

谢谢。

4

1 回答 1

1

这是向所有页面添加额外列的 app/design/frontend/mypackage/default/layout/local.xml。被注释掉的句柄已被注释,因为它们仅适用于通过管理面板配置为 CMS 页面的页面。

<?xml version="1.0"?>
<layout version="0.1.0">
  <default>
    <reference name="root">
      <block type="core/template" name="outer-left" template="page/outer-left.phtml" />
      <block type="core/template" name="outer-right" template="page/outer-right.phtml" />
    </reference>
  </default>
   <!--
  <page_one_column>
    <reference name="root">
      <block type="core/template" name="outer-left" template="page/outer-left.phtml" />
      <block type="core/template" name="outer-right" template="page/outer-right.phtml" />
    </reference>
  </page_one_column>
  <page_two_columns_left>
    <reference name="root">
      <block type="core/template" name="outer-left" template="page/outer-left.phtml" />
      <block type="core/template" name="outer-right" template="page/outer-right.phtml" />
    </reference>
  </page_two_columns_left>
  <page_two_columns_right>
    <reference name="root">
      <block type="core/template" name="outer-left" template="page/outer-left.phtml" />
      <block type="core/template" name="outer-right" template="page/outer-right.phtml" />
    </reference>
  </page_two_columns_right>
  <page_three_columns>
    <reference name="root">
      <block type="core/template" name="outer-left" template="page/outer-left.phtml" />
      <block type="core/template" name="outer-right" template="page/outer-right.phtml" />
    </reference>
  </page_three_columns>
  -->
</layout>
于 2013-06-17T17:30:45.447 回答