Created
September 30, 2012 10:40
-
-
Save vdubyna/3806428 to your computer and use it in GitHub Desktop.
Add block on the fly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<config> | |
<modules> | |
<Myspace_Fpcblock> | |
<version>0.0.1</version> | |
</Myspace_Fpcblock> | |
</modules> | |
<global> | |
<blocks> | |
<myspace_fpcblock> | |
<class>Myspace_Mymodule_Block</class> | |
</myspace_fpcblock> | |
</blocks> | |
<models> | |
<myspace_fpcblock> | |
<class>Myspace_Mymodule_Model</class> | |
</myspace_fpcblock> | |
</models> | |
<events> | |
<controller_action_layout_render_before_cms_index_index> | |
<observers> | |
<add_time_before_content> | |
<class>Myspace_Fpcblock_Model_Observer</class> | |
<method>prependTimeBlock</method> | |
</add_time_before_content> | |
</observers> | |
</controller_action_layout_render_before_cms_index_index> | |
</events> | |
</global> | |
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Myspace_Fpcblock_Model_Observer | |
{ | |
public function prependTimeBlock($observer) | |
{ | |
/** @var $layout Mage_Core_Model_Layout */ | |
$layout = Mage::app()->getLayout(); | |
$block = $layout->createBlock( | |
'Mage_Core_Block_Text', | |
'myspace_fpcblock_time', | |
array('text' => "Generation Time: " . date('H:i:s')) | |
); | |
$layout->getBlock('content')->insert($block); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment