You are browsing documentation for version 5.0 of OroCommerce, supported until January 2025. Read the documentation for version 6.0 (the latest LTS version) to get up-to-date information.

See our Release Process documentation for more information on the currently supported and upcoming releases.


Create a Dashboard Widget 

To display a list of tasks on the dashboard with the most recent tasks:

  1. Create a data grid that collects and displays the tasks’ data while ensuring that the most recent tasks are displayed on top.

  2. Create a Twig template that renders the grid.

  3. Сonfigure the dashboard widget by telling it which template to render.

Configuring the Grid 

The data grid that will be displayed on the dashboard can be based on the already existing app-tasks-grid that you used to show a grid of all the tasks being present. Sort the result (the id can be used as a sorting criterion as more recent tasks will have higher ids):

     # ...
         extends: app-tasks-grid
                 id: DESC

Widget Template 

To render the data grid on the dashboard, create a Twig template based on the @OroDashboard/Dashboard/widget.html.twig template. You will need to create a template called recent_tasks_widget.html.twig located in the Resources/views/Dashboard directory of you bundle (see Adding Widget Configuration for an explanation of the schema to follow for the template name and location) with the following content:

 {% extends '@OroDashboard/Dashboard/widget.html.twig' %}
 {% import '@OroDataGrid/macros.html.twig' as dataGrid %}

 {% block content %}
     {{ dataGrid.renderGrid('app-recent-tasks-grid') }}
 {% endblock %}

 {% block actions %}
     {% set actions = [{
         'url': path('app_task_index'),
         'type': 'link',
         'label': 'All tasks',
     }] %}

     {{ parent() }}
 {% endblock %}

Adding Widget Configuration 

             label: Recent Tasks
             route: oro_dashboard_widget
                 bundle: AppBundle
                 name: recent_tasks_widget
             description: This widget displays the most recent tasks

The configured oro_dashboard_widget route refers to a controller action that comes as part of the Oro\Bundle\DashboardBundle\Controller\DashboardController and renders a template whose name is inferred from route parameters (the name of the template that the controller is looking for follows the {{bundle}}:Dashboard:{{name}} pattern where {{bundle}} and {{name}} refer to the route parameters of the dashboard config).


If your widget contains some more logic (e.g., calling some service and doing something with its result), you can create your own controller, configure a route for it, and then refer to this route with the route key in your widget configuration.