As I mentioned in the previous post, today I’ll continue bringing to you further knowledge of blocks. This tutorial will also be the last part in our series of posts about blocks, covering 3 major contents:

  • Identify different types of blocks
  • Disable output block
  • Describe how a typical block is rendered

1. Identify different types of blocks

a. Structural block
Structural block is used to define the layout/structure for template system in Magento. It’s parent block of content block and to locate block area for its content block. As usual, the structural blocks don’t work along with data in system. One typical example for the structural block is core/text_list block.
Features of structural blocks:

  • No need to accompany with template file
  • No display anything if not having children blocks
  • Every content block which is children block of this structural block will be shown its content here

b. Content block
Content blocksare used to show the content. These blocks will take data in the system and display them. (In most cases, they will be attached to template file). page/html_welcome block is one of examples for the content block.

  • A content block is only displayed when it is attached to a astructural block (or have to be called from cms page)
  • Block takeswelcome_messagedatastoredin the system and shows them.

2. Disable output block
To disable output block of module, we can adjust in configuration: System >> Configuration >> Advanced >> Disable modules output. Go to module and disable. At this time, all blocks of module will not be rendered to html.

3. Describe how a typical block is rendered

The process to render a block is as below:

  • The layout or a parent block calls toHtmlfunctionof a block to get string html which the block displays.

– Block checks and confirms that the output block was enabled

– Block calls the following functions in turn: _beforeToHtml(), _toHtml(), _afterToHtml().

  • The process to output to html:

– Fetching View is to find the template file which is set for block

– Block checks configuration template path hint to bring out template path hint for block

– Block will include template file to render to html

– At the end, the block will return html to parent block that called it.


Well, the Block chapter ends here. That’s all I want to tell you about blocks. Hope that my articles will make you completely understand blocks as well as their features.

Goodbye! I’ll be back in our next posts.

Author

Why Magestore? We believe in building a meaningful & long-term relationship with you.

Write A Comment