Widgets or Partials? It seems to be a trivial question. However, this is something bugs me every time.
When to use Widgets
Widgets should be used whenever some application logic is present. It is a convenient way to encapsulate as a separate and standalone component
Here are a few things that come to mind:
- Menus — Sometimes we need to access the Menu data from the database. This can be retrieved by the Controller and sent to the view. However, making this in a Widget will make it DRY whenever you repeatedly use it elsewhere.
When to use Partials
Partials is a convenient way to reuse code. Most of the uses don’t require much logic. You usually choose it when all the variables it need to access are already prepared in the current action.