【问题标题】:My custom CMS Layout Template in Magento is not loaded我在 Magento 中的自定义 CMS 布局模板未加载
【发布时间】:2013-09-26 14:37:14
【问题描述】:

我已经根据this tutorial 为 Magento 创建了自定义 CMS 布局。在我的本地主机(Win7 上的 XAMPP)上它正在工作,但是当我将所有 3 个文件上传到我的网站时:

  • app/code/local/Lorinc/cmsLayout/etc/config.xml
  • app/design/frontend/sportsfans01/default/template/page/cmsLayout.phtml
  • app/etc/modules/Lorinc_cmsLayout.xml

它在那里不起作用。 这是config.xml

的代码
<?xml version="1.0"?>
<config>
<modules>
    <Lorinc_cmsLayout>
      <version>0.1.0</version>
    </Lorinc_cmsLayout>
  </modules>
  <global>
    <page>
      <layouts>
        <cmsLayout translate="label">
          <label>cmsLayout</label>
          <template>page/cmsLayout.phtml</template>
          <layout_handle>cmsLayout</layout_handle>
        </cmsLayout>
        <!-- add more layouts here -->
      </layouts>
    </page>
  </global>
</config>

这里是 Lorinc_cmsLayout.xml

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

我什么都试过了。我更改了文件和文件夹权限(文件 0644,文件夹 0755),我使用了magento-cleanup.php,我的缓存被禁用,我尝试注销并再次登录,但没有任何效果。有什么想法有什么问题吗?

【问题讨论】:

    标签: magento magento-1.7


    【解决方案1】:

    刚看了你的问题,我看到的第一件事就是你的文件夹结构错误:

    路径app/design/frontend/sportsfans01/default/template/page/cmsLayout.phtml

    必须改成

    app/design/frontend/default/sportsfans01/template/page/cmsLayout.phtml

    不知道是不是你的笔误!

    另外你可以查看magento的日志:

    var/log/exception.log var/log/system.log

    希望这会有所帮助

    问候

    文斯

    【讨论】:

    • 嗨文斯。感谢您的尝试,但没有帮助。第一件事:我很确定,路径是正确的,因为我在本地主机上使用相同的路径并且它可以工作,而且我对另一个布局使用相同的路径并且它也可以工作。以防万一我试过你的路,但什么也没发生。第二件事。这是我打开 CMS > Pages > 并单击要编辑的页面时的日志:
    • 2013-09-26T17:01:57+00:00 调试 (7):标头已发送:
      [0] /data/web/virtuals/49304/virtual/www/app /code/core/Mage/Core/Controller/Response/Http.php:52 [1] /data/web/virtuals/49304/virtual/www/lib/Zend/Controller/Response/Abstract.php:766 [2] /data/web/virtuals/49304/virtual/www/app/code/core/Mage/Core/Controller/Response/Http.php:83 [3] /data/web/virtuals/49304/virtual/www/app/ code/core/Mage/Core/Controller/Varien/Front.php:188 [4] /data/web/virtuals/49304/virtual/www/app/code/core/Mage/Core/Model/App.php:354 [5] /data/web/virtuals/49304/virtual/www/app/Mage.php:683
    • [6] /data/web/virtuals/49304/virtual/www/index.php:87 对我来说帮助不大。你懂吗?
    【解决方案2】:

    请试试这个。我在 App/code/core/Mage/Page/etc/config.xml 中找到了 1column.phtml 布局

    <global>
        <page>
          <layouts>
            <cmsLayout module="page" translate="label">
              <label>cmsLayout</label>
              <template>page/cmsLayout.phtml</template>
              <layout_handle>page_cmsLayout</layout_handle>
            </cmsLayout>
            <!-- add more layouts here -->
          </layouts>
        </page>
    </global>
    

    如果这没有帮助,请尝试更改不同的主题文件夹。一定要避免拼写错误。

    【讨论】:

    • 嗨chirag。谢谢,但这不是最佳解决方案。当您更改某些核心文件时,您将在更新期间丢失它们。第二件事。我的文件中不应该有任何类型,因为我只是从我的本地主机复制它们,它在那里工作。
    • @Posuk13 我不是在谈论更改核心文件,我只是说我从核心文件中找到了上面的 sn-p,所以可能对您的自定义文件有所帮助。但是现在您的问题解决了.太好了。谢谢。
    【解决方案3】:

    问题终于解决了。我在那个页面上已经有一个自定义布局(称为 HomeLayout),所以我只是合并了这 2 个布局。这里是app/code/local/Lorinc/HomeLayout/etc/config.xml的代码

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

    而且效果很好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-13
      • 1970-01-01
      • 2013-06-16
      • 2012-03-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多