简体   繁体   English

如何在.phtml文件中调用magento扩展名的静态块?

[英]How to call a static block of magento extension in .phtml file?

I have installed an extension for slider on my home page. 我在主页上安装了滑块扩展程序。 It has given me a static block code. 它给了我一个静态的块代码。

 Call via block:
 {{block type="responsivebannerslider/index" name="responsivebannerslider_index" template="responsivebannerslider/index.phtml"}}

Dont know how call it in .phtml file? 不知道如何在.phtml文件中调用它?

You can call it from your template by creating a block on the layout directly in the phtml template file: 您可以通过直接在phtml模板文件中的布局上创建一个块来从模板中调用它:

<?php echo $this->getLayout()->createBlock('responsivebannerslider/index')->setTemplate('responsivebannerslider/index.phtml')->toHtml(); ?>

Or if the block is listed in the extensions layout XML file, (which would be nested within a reference node), and would look something like: 或者,如果该块在扩展布局XML文件中列出(该块将嵌套在参考节点中),则其外观类似于:

<block type="responsivebannerslider/index" name="responsivebannerslider_index" as="an_alias" template="responsivebannerslider/index.phtml">
    <label>Responsive banner</label>
</block>

And you'd call that in your template file like: 您可以在模板文件中调用它,例如:

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

\n
\n
\n
<?php echo $this->getLayout()->createBlock('responsivebannerslider/index')->setTemplate('responsivebannerslider/index.phtml')->toHtml(); ?>
\n
\n
\n

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

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