简体   繁体   English

如何在magento的specfic页面调用.phtml块?

[英]How do i call .phtml block at specfic page in magento?

How do i use test.phtml at test page i used following code but it didnt work 我如何在测试页面使用test.phtml我使用下面的代码,但它没有工作

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

But it didnt show anything at the page. 但它没有在页面上显示任何内容。 So did i missed anything? 我错过了什么吗? do i need to put some code in other files, like page.xml or local.xml. 我需要将一些代码放在其他文件中,例如page.xml或local.xml。

Thanks 谢谢

your code looks good for to add in CMS page. 您的代码看起来很适合在CMS页面中添加。 if you want to add .phtml file in a .phtml file then you can use like this. 如果你想在.phtml文件中添加.phtml文件,那么你可以像这样使用。 you don't need to add anything in xml file 您不需要在xml文件中添加任何内容

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

thanks 谢谢

Try this. 尝试这个。 First create a page in CMS pages in admin panel and add the following code to the content of the CMS page. 首先在管理面板的CMS页面中创建一个页面,然后将以下代码添加到CMS页面的内容中。 It will call the content of this page in the main content area. 它将在主要内容区域中调用此页面的内容。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM