3

What is a "widget" in TYPO3?

I'm having some challenges creating an extension, and I'm seeing a lot of references to "widgets" doing this and that.

I don't know if "widget" is synonymous with "extension". I don't know if it would be a special kind of extension, or if an extension may contain several widgets.

I've probably spent 20-30 hours of the last week reading documentation, and I am ever so close to my goals. Please, kind sirs and madams, pray tell what exactly is a widget (in TYPO3)?

Daniel
  • 6,916
  • 2
  • 36
  • 47
nHaskins
  • 805
  • 8
  • 22

1 Answers1

4

You can take a look at Flow documentation definition of Widgets. The main conclusions are:

  1. Widget - is a special ViewHelper, which is used in Fluid templates. So, your extension may contain as many widgets, as you want.
  2. Widget must contain an own Controller. So, this makes is different from a ususal ViewHelper, since ViewHelpers are usually stateless and they don't take part in MVC process. But Widgets can contain a state and they are part of MVC, so can be treated as special plugins.
  3. Widgets are bound to caller context. It means, that if Controller of your Widget looks for $this->settings, then settings will be read from an extension, that uses a Widget (this was my experience in TYPO3 6.2).

So, as you see - Widget is a ViewHelper and Plugin at same time. A good example of Widget is f:widget.paginate - it can be used in Fluid template of any extension, and at same time it fully interacts with MVC stack.

Viktor Livakivskyi
  • 3,178
  • 1
  • 21
  • 33
  • new link: https://docs.typo3.org/other/typo3/view-helper-reference/10.4/en-us/typo3/fluid/latest/Widget/Paginate.html And beware, it is deprecated sind TYPO3 10.4. – Franz Holzinger Apr 22 '23 at 19:01