【问题标题】:MAgento new blockMAgento 新区块
【发布时间】:2013-08-22 01:28:45
【问题描述】:

这是我的结构: 在 [template_name]/default/layout/page.xml 我创建了新块:

<block type="core/text_list" name="customblock" template="page/html/customblock.phtml" />

在 [模板名称]/default/template/1column.phtml 中

<?php echo $this->getChildHtml('customblock') ?>

并且在 [template_name]/default/template/page/html/customblock.phtml 中是

<h1 style="bacground-color:yellow">Hello this is new reference</h1>

异常日志是空的,我的新块没有显示,有人知道为什么吗?

【问题讨论】:

    标签: php magento


    【解决方案1】:

    你可以做两件事你的目录不正确请改变你的目录 将您的模板放在页面/开关中 并在 page.xml 中调用如下

     <block type="page/switch" name="customblock" as="customblock" template="page/switch/customblock.phtml"/>
    

    并将您的自定义块添加到default/template/page/switch/yourblock.phtml

    或者另一种方式是

    如果您要使用模板 (phtml),您的块应从 Mage_Core_Block_Template 扩展。

    所以你的块类型应该是core/template

    希望这一定能解决您的问题

    【讨论】:

    • 两个都试过了,还是不行
    • 请您清除缓存好吗?如果你想创建你的简单模板试试expertwebadvisor.com/…
    • 我已禁用缓存
    【解决方案2】:

    这对我很有帮助:

     <block type="core/text_list" name="customblock" as="customblock" translate="label">
          <label>featured block</label>
          <block type="page/html_topmenu" template="page/html/customblock.phtml"/>
      </block>
    

    【讨论】:

      猜你喜欢
      • 2011-09-20
      • 1970-01-01
      • 2012-12-10
      • 2014-05-22
      • 1970-01-01
      • 2023-01-29
      • 1970-01-01
      • 1970-01-01
      • 2011-05-21
      相关资源
      最近更新 更多