Skip to main content

Widgets

Widget controllers are specialised component controllers. They interact with the Homepage designer feature of Jadu Central.

Widgets are registered within the theme services.yml configuration file.

photon_cms_project.widget.website_statistics:
class: WebsiteStatisticsWidget
parent: photon.controller.widget
arguments:
- '@photon.repository.website_statistics'
tags:
- { name: photon.widget, widget_id: 31 }

Widget services must be tagged with photon.widget and with the parameter widget_id. The id must match the corresponding database entry in JaduHomepageWidgets.

tip

When no matching widget service is found, the default widget service is used, with widget_id = 1. The default widget will pass code stored in the database through the function eval() to generate the response returned from the controller.

Invoking widgets

Widgets are not invoked by a route, but instad by using the widget() Twig function.

{{ widget(widgetRecord) }}

A widget record must be passed as a parameter to the widget() function.