- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2017
05:28 AM
02-10-2017
05:28 AM
Calling block from phtml
Inside my 1column.phtml I have this piece of code:
<?php echo $this->getChildHtml('wide'); ?>
Inside my app/design/frontend/enterprise/wk/layout/wk.xml I have:
<cms_index_index> <reference name="wide"> <block type="wk/geotarget" name="geotarget"/> </reference> </cms_index_index>
Inide app/code/local/Company/Module/Block/Geotarget.php I have:
class Company_Module_Block_Geotarget extends Mage_Core_Block_Template { protected function _toHtml() {
$layout = Mage::getSingleton('core/layout'); // Generate a CMS block object
$block = $layout->createBlock('cms/block'); // Set the block ID of the static block
$block->setBlockId('homepage-hero'); return parent::_toHtml(); } }
How do I render this static block based on block ID? I need to do some custom logic inside that Block to get some specific or random block and render it.
Labels:
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2017
08:57 AM
02-10-2017
08:57 AM
Re: Calling block from phtml
Hi @dario_inchoo,
What if you change the <block> definition for something like this:
<block type="cms/block" name="geotarget"> <action method="setBlockId"> <block_id>homepage-hero</block_id> </action> </block>