【问题标题】:Magento custom layout works only locallyMagento 自定义布局仅在本地工作
【发布时间】:2014-04-23 07:12:27
【问题描述】:

运行一个 Magento CE 1.8 站点,需要使用基于 1column.phtml 布局的自定义页面布局设置一个非常基本的 CMS 页面。我创建了布局,并且能够在本地管理员中选择它,但是在将我的更改推送到远程时,自定义布局在远程站点上不可用,只有我的本地主机。

我已经清除了缓存,删除了远程上的会话和缓存目录,四重检查了所有必要的文件是否已添加到提交并推送,然后注销并重新登录(几次),只是为了确保.还是什么都没有..我想不通!这是 Magento 中最简单的事情之一,它显然可以在本地工作,但我找不到本地和远程之间的差异。我知道这可能很容易,但我很难过。尝试了一些我发现的答案,但似乎没有任何效果 - 尽管My custom CMS Layout Template in Magento is not loaded 会这样做但没有骰子。

代码如下,如果有帮助的话:

/app/code/local/styleguide/etc/config.xml:

<?xml version="1.0"?>
<config>
  <modules>
    <styleguide>
      <version>0.1.0</version>
    </styleguide>
  </modules>
  <global>
    <page>
      <layouts>
        <style_guide translate="label">
          <label>style_guide</label>
          <template>page/styleguide.phtml</template>
          <layout_handle>style_guide</layout_handle>
        </style_guide>
        <!-- add more layouts here -->
      </layouts>
    </page>
  </global>
</config>

/app/design/frontend/MY_THEME/default/template/page/styleguide.phtml:

<?xml version="1.0"?>
<config>
  <modules>
    <styleguide>
      <version>0.1.0</version>
    </styleguide>
  </modules>
  <global>
    <page>
      <layouts>
        <style_guide translate="label">
          <label>style_guide</label>
          <template>page/styleguide.phtml</template>
          <layout_handle>style_guide</layout_handle>
        </style_guide>
        <!-- add more layouts here -->
      </layouts>
    </page>
  </global>
</config>

/app/etc/modules/styleguide.xml:

<?xml version="1.0"?>
<config>
  <modules>
    <styleguide>
      <active>true</active>
      <codePool>local</codePool>
      <depends>
        <Mage_Page />
      </depends>
    </styleguide>
  </modules>
</config>

【问题讨论】:

    标签: xml magento model-view-controller magento-1.7 magento-1.8


    【解决方案1】:

    我认为你的文件夹结构路径有问题..

    正如上面提到的/app/code/local/styleguide/etc/config.xml,您的命名空间路径丢失了。一般它必须如下:app/code/local/Namespace/Module/etc/config.xml,并且您的模块名称必须以大写字母开头。

    但这里是小写字母。而且你的 module.xml 也是错误的。app/etc/modules/Namespace_Module.xml 的 module.xml 中没有命名空间它必须如下:

    <?xml version="1.0"?>
    <config>
    <modules>
        <Namespace_Home>
        <active>true</active>
        <codePool>local</codePool>
        </Namespace_Home>
    </modules>
     </config>
    

    你能先检查所有这些东西吗..

    【讨论】:

    • 非常感谢 - 不太熟悉 Magento 的命名结构。你的回答让我走了大约 90% 的路,而这个 (magento.stackexchange.com/questions/1140/…) 让我走完了剩下的路。可能是我在任何系统上创建自定义子主题时最尴尬的方式,哈哈。
    猜你喜欢
    • 1970-01-01
    • 2013-09-28
    • 1970-01-01
    • 2021-09-01
    • 1970-01-01
    • 2012-07-10
    • 2015-01-16
    • 2013-09-13
    • 2022-12-15
    相关资源
    最近更新 更多