Dashboard
=========
The Dashboard is the main landing page. By default it lists your mapped models,
as defined by you using ``Admin`` services. This is useful to help you start using
``SonataAdminBundle`` right away, but there's much more that you can do to take
advantage of the Dashboard.
The Dashboard is, by default, available at ``/admin/dashboard``, which is handled by
the ``SonataAdminBundle:Core:dashboard`` controller action. The default view file for
this action is ``SonataAdminBundle:Core:dashboard.html.twig``, but you can easily change
it in your ``config.yml``:
.. code-block:: yaml
# app/config/config.yml
sonata_admin:
templates:
dashboard: SonataAdminBundle:Core:dashboard.html.twig
.. note::
This view, like most of ``SonataAdminBundle`` views, extends a global
template file, which also contains significant parts to the page. More information
about this is available in the :doc:`templates` chapter.
Blocks
------
The Dashboard is actually built using ``Blocks`` from ``SonataBlockBundle``. You
can learn more about this bundle and how to build your own Blocks in its `documentation page`_.
An example of a ``Block`` is the above mentioned ``Admin`` list. It is actually implemented as a
``SonataBlockBundle`` block, that displays your configured ``Admin`` services in a nicely
formated list.
The ``Admin`` list
------------------
The ``Admin`` list is a ``Block`` that fetches information from the ``Admin`` services ``Pool``
and prints it in the nicely formated list you have on your default Dashboard.
The ``Admin`` list is defined by the ``sonata.admin.block.admin_list`` service, which is
implemented by the ``Block\AdminListBlockService`` class. It is then rendered using the
``SonataAdminBundle:Block:block_admin_list.html.twig`` template file.
Feel free to take a look at these files. You'll find the code rather small and easy to
understand, and will be a great help when implementing your own blocks.
Configuring the ``Admin`` list
------------------------------
As you probably noticed by now, the ``Admin`` list groups ``Admin`` mappings together.
There are several ways in which you can configure these groups.
Using the ``Admin`` service declaration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The first, and most commonly
used, is when defining your ``Admin`` service:
.. code-block:: xml
This is a sonata.block.service.text
from the Block Bundle, you can create and add new block in these area by configuring the sonata_admin
section.
sonata.block.service.rss
):"} }
- { position: right, type: sonata.block.service.rss, settings: { title: Sonata Project's Feeds, url: http://sonata-project.org/blog/archive.rss }}
.. note::
Blocks may accept/require additional settings to be passed in order to
work properly. Refer to the associated documentation/implementation to
get more information on each block's options and requirements.
Display two ``Admin`` list blocks with different dashboard groups
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The same block can have multiple instances, and displayed multiple time
across the Dashboard. An particular example is the ``Admin`` list block,
which can be configured to better fit this scenario.
.. code-block:: yaml
# app/config/config.yml
sonata_admin:
dashboard:
blocks:
# display two dashboard blocks
- { position: left, type: sonata.admin.block.admin_list, settings: { groups: [sonata_page1, sonata_page2] } }
- { position: right, type: sonata.admin.block.admin_list, settings: { groups: [sonata_page3] } }
groups:
sonata_page1:
items:
- sonata.page.admin.myitem1
sonata_page2:
items:
- sonata.page.admin.myitem2
- sonata.page.admin.myitem3
sonata_page3:
items:
- sonata.page.admin.myitem4
In this example, you would have two ``Admin`` list blocks on your dashboard, each of
them containing just the respectively configured groups.
.. _`documentation page`: http://sonata-project.org/bundles/block/master/doc/index.html