简体   繁体   中英

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?

You can call it from your template by creating a block on the layout directly in the phtml template file:

<?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:

<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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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