Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Magento Block and Block Type

Tags:

magento

block

I just want to understand the meaning of

 <block type="page/html" name="root" output="toHtml" template="example/view.phtml"> 

I got many references from Google and understood many things about it but I am still unable to understand the formation of type="page/html" how to form a type for my custom module.

Please explain

type="A/B" 

Let me know where this A and B come from?

like image 292
Anup_Tripathi Avatar asked Jul 09 '11 07:07

Anup_Tripathi


People also ask

How many types of blocks Magento?

There are two phases of the block life cycle: generating blocks and rendering blocks.

What are blocks in Magento?

Magento block is a modular unit of content that can be placed anywhere on the page. Blocks in Magento are referred to as static blocks or CMS blocks. They help to display fixed information such as text, images, and embedded video, as well as dynamic information from a widget that originates through the database.

What is the functional difference of block & container in Magento 2?

In Magento, the basic components of page design are layouts, containers, and blocks. A layout represents the structure of a web page (1). Containers represent the placeholders within that web page structure (2). And blocks represent the UI controls or components within the container placeholders (3).

What is the default block class?

<update> <argument> <block> vs <container>


1 Answers

For understanding more about magento block types following are some built-in block types which are widely used in layout.

  1. core/template: This block renders a template defined by its template attribute. The majority of blocks defined in the layout are of type or subtype of core/template.
  2. page/html: This is a subtype of core/template and defines the root block. All other blocks are child blocks of this block.
  3. page/html_head: Defines the HTML head section of the page which contains elements for including JavaScript, CSS etc.
  4. page/html_header: Defines the header part of the page which contains the site logo, top links, etc.
  5. page/template_links: This block is used to create a list of links. Links visible in the footer and header area use this block type.
  6. core/text_list: Some blocks like contentleftright etc. are of type core/text_list. When these blocks are rendered, all their child blocks are rendered automatically without the need to call thegetChildHtml() method.
  7. page/html_wrapper: This block is used to create a wrapper block which renders its child blocks inside an HTML tag set by the action setHtmlTagName. The default tag is <div> if no element is set.
  8. page/html_breadcrumbs: This block defines breadcrumbs on the page.
  9. page/html_footer: Defines footer area of page which contains footer links, copyright message etc.
  10. core/messages: This block renders error/success/notice messages.
  11. page/switch: This block can be used for the language or store switcher.

This is a list of only commonly used block types. There are many other block types which are used in advanced theme implementations.

like image 123
Kamesh Jungi Avatar answered Sep 28 '22 18:09

Kamesh Jungi