Magento block reference order -
i created custom extension on magento render block on main content. how choose order displayed? right being displayed below content. there way define after or before block? how see name of blocks render before or after?
app/code/local/spacename/infrontpage/block/infrontpage.php <?php class rand_infrontpage_block_infrontpage extends mage_core_block_template{ function getcustombanner() { return 'fernandao custom block'; } } ?>
then have:
app/code/local/spacename/infrontpage/etc/config.xm<?xml version="1.0"?> <config> <modules> <rand_infrontpage> <version>0.1.0</version> </rand_infrontpage> </modules> <global> <blocks> <infrontpage> <class>rand_infrontpage_block</class> </infrontpage> </blocks> </global> <frontend> <layout> <updates> <infrontpage> <file>infrontpage.xml</file> </infrontpage> </updates> </layout> </frontend> </config>
and:
app/design/frontend/base/default/layout/infopage.xml <?xml version="1.0"?> <layout version="0.1.0"> <cms_index_index> <reference name="content"> <block type="infrontpage/infrontpage" name="infrontpage" template="infrontpage/infrontpage.phtml" /> </reference> </cms_index_index> </layout>
and finally:
app/design/frontend/base/default/template/infrontpage/infrontpage.phtml\ <h1 class="infrontpage" style="text-align: center;"><?php echo $this->getcustombanner(); ?></h1>
in magento before="child.block.name"
, after="child.block.name"
attributes used define order of blocks. if attributes not specified blocks render in order magento reads them.
for example
<reference name="root"> <block type="core/template" name="example_block" before="content" template="page/html/example-block.phtml"/> </reference>
Comments
Post a Comment