The module is now prepared for the real work. In the previous recipes, we prepared the module with the most common features. In this recipe, we will add a block of new products in our previously created page.
To create a custom block, we have to create a Block
class in the Block
folder of the Packt_Helloworld
module, a layout instruction to add the block to our page, and a phtml
template in our theme to style the HTML output of the block.
The following steps describe how to add a block with new products to the frontend:
Create the
block
class inapp/code/local/Packt/Helloworld/Block
. The name of the class isNewproducts
, so we have to create aNewproducts.php
file in this folder.Add the following content in the file. This will create a class that extends the
Mage_Core_Block_Template
class. This class will output a template if specified:<?php class Packt_Helloworld_Block_Newproducts extends Mage_Core_Block_Template { }
Add the...