【问题标题】:How do i call .phtml block at specfic page in magento?如何在 magento 的特定页面调用 .phtml 块?
【发布时间】:2014-03-18 15:25:01
【问题描述】:

我如何在测试页面上使用 test.phtml 我使用了以下代码但它没有工作

{{block type='core/template' name='Test' template='goodtest/test.phtml'}} 

但它没有在页面上显示任何内容。所以我错过了什么吗?我是否需要将一些代码放在其他文件中,例如 page.xml 或 local.xml。

谢谢

【问题讨论】:

  • 你的模板的magento相对路径是什么?

标签: magento


【解决方案1】:

您的代码看起来很适合添加到 CMS 页面中。 如果你想在 .phtml 文件中添加 .phtml 文件,那么你可以像这样使用。 您不需要在 xml 文件中添加任何内容

    <?php 
  echo $this->getLayout()->createBlock('core/template')->setTemplate('goodtest/test.phtml')->toHtml();
?>

谢谢

【讨论】:

    【解决方案2】:

    试试这个。 首先在管理面板的 CMS 页面中创建一个页面,并将以下代码添加到 CMS 页面的内容中。它会在主内容区调用本页的内容。

    {{block type='page/html' template='page/html/demo.phtml'}}
    

    【讨论】:

      猜你喜欢
      • 2012-09-30
      • 2017-01-17
      • 2015-03-21
      • 1970-01-01
      • 2014-04-26
      • 2016-03-21
      • 2016-09-19
      • 1970-01-01
      • 2015-01-29
      相关资源
      最近更新 更多