简体   繁体   English

如何在另一个块phtml文件中调用自定义模块块

[英]how to call a custom module block in another block phtml file

How to call a block in another block phtml file? 如何在另一个块phtml文件中调用块? I have created a module to display special product. 我创建了一个显示特殊产品的模块。 My Question is that in featured product phtml file ,i have to check there is any special product,if present i want to display special product otherwise fetured product should be displayed. 我的问题是,在特色产品phtml文件中,我必须检查是否有任何特殊产品,如果存在我想显示特殊产品,否则应显示产品。

you can call your custom block file in to another custom template files as below 您可以将自定义块文件调用到另一个自定义模板文件中,如下所示

<?php echo Mage::getSingleton('core/layout')->createBlock('custom/mycustomblock')->setTemplate('custom/test.phtml')->toHtml(); ?>

hope this will help you. 希望这会帮助你。

Create a helper class method in your custom module to check the special product condition. 在自定义模块中创建辅助类方法以检查特殊产品条件。 your helper class will return the true or false value to your module block files (.phtml). 你的助手类会将true或false值返回给你的模块块文件(.phtml)。

Call the module helper calls in using below code. 使用下面的代码调用模块助手调用。

Mage::helper('yourmodule')->checkSpecialProduct();

try this one. 试试这个。

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

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