Magento – the difference between block and widget code

blockswidgets

This code gives me a bunch of products:

 {{block type="catalog/product_list" limit="4" category_id="13" template="catalog/product/list.phtml"}}

This code gives me nothing:

 {{widget type="catalog/product_list" limit="4" category_id="13" template="catalog/product/list.phtml"}}

Why does the "block" version work out of the box and the widget code does not?

Best Answer

Widgets:

  • small applets/components, that means it has behavior, logic, and/or side-effects.
  • can contain a block widget (a small script that renders a block).
  • fixed based on type; cannot have custom content.

Blocks:

  • Have no logic.
  • flexible containers, used to display text, child blocks or widgets.
  • provide a bridge for config, layout for its views/components.
Related Topic