Kashif Raza
Kashif Raza

Reputation: 84

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?

Upvotes: 0

Views: 748

Answers (2)

PhilS
PhilS

Reputation: 365

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'); ?>

Upvotes: 2

Mohammad Aktaruzzaman
Mohammad Aktaruzzaman

Reputation: 74

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

Upvotes: 1

Related Questions