Widget system

From Dolibarr ERP CRM Wiki
Revision as of 08:59, 21 August 2014 by Rdoursenaud (talk | contribs) (Sync with french)
Jump to navigation Jump to search

A box is a rectangular area that can be displayed on some pages (like the home page). These are described using files in a specific directory.

Boxes content is left to the developer's imagination (graphics, text, tables, …).



Art.png Create a new box

Every standard box is stocked inside the directory htdocs/core/boxes. There is one file for each box.

Each file is a class inherited from the ModeleBoxes class.

To create a new box, copy an existing box file and rename it, for example to box_myownbox.php. Change its content to match the new name and define informations you want to show inside the box.

However if you plan distributing your box to other users, you should create a module instead and store your box files inside your module.

  • Go to Module development page to learn how to create a module
  • Copy the box file to htdocs/mymodule/core/boxes/
  • Once your module descriptor is created, add these lines to declare your box file
$this->boxes = array(
    0 => array(
        'file' => 'box_myownbox@mymodule',
        'note' => 'My notes',
        'enabledbydefaulton' => 'Home'
    )
    // You can declare as much boxes as you want by simply incrementing the index.
);

Art.png Activate a box

To activate a box, go to Home - Setup - Boxes page and click activate on the box you want to see. It will be displayed on the page for which you have activated the box.