How to load a Custom PHP Magento Block inside a template file -


i've created custom block based on tutorial http://blog.magikcommerce.com/how-to-show-most-viewed-best-selling-products-in-magento-store

i call block home.phtml template file.

i call static blocks from:

<?php $helper = mage::helper('cms'); $source = mage::getmodel('cms/block')->load('my-block'); $processor = $helper->getpagetemplateprocessor(); $html = $processor->filter($source->getcontent()); echo $html; ?> 

and works charm, of course! ' how can load dynamic blocks, in case, inside template files.

my bestseller.phtml file is:

app/design/frontend/default/default/template/catalog/product/bestseller.phtml 

and class is:

mage_catalog_block_product_bestseller  

loading block template file bad style, possible.

the dirty way template file

echo $this->getlayout()->createblock('catalog/product_bestseller')->tohtml(); 

the clean way:
go layout xml file add block anyother , refer with

echo $this->getchildhtml('product_bestseller'); 

if in cms page use "layout xml updates" section under design like

<reference name="content">     <block type="catalog/product_bestseller" name="product_bestseller" /> </reference> 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -