Widget system: Difference between revisions

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search
No edit summary
Tag: 2017 source edit
 
(14 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<!-- BEGIN origin interlang links -->
<!-- You can edit this section but do NOT remove these comments
    Links below will be automatically replicated on translated pages by PolyglotBot -->
[[fr:Système_des_Widgets]]
[[es:Sistema_de_paneles]]
[[de:System fuer Wigets]]
[[zh:信息框]]
<!-- END interlang links -->
[[Category:Core]]
[[Category:Core]]
{{TemplateDocDevEn}}
{{TemplateDocDevEn}}


A box is a file placed into a particular directory and that allows to add new informations in a rectangular area on some pages like the home page.
A box is a rectangular area that can be displayed on some pages (only the home page for moment). These are described by files in a specific directory.


Boxes content is left to the developer's imagination (graphics, text, tables, …) but a basic framework allows for easy table based presentation.


= [[File:art.png]] Create a new Widget =


Every standard box is stored inside the '''htdocs/core/boxes''' directory.


There is one file for each box.


Each file is a class inherited from the '''ModeleBoxes''' class.


To create a new box, you may copy an existing box file, rename it, for example to '''box_myownbox.php''' and change its content to match the new name.


= [[File:art.png]] Create a new box =
You can now define the informations you want to show inside the box.
Every standard box is stocked inside the directory '''htdocs/core/boxes'''.
There is one file for each box.


Each file is a PHP class that herits the class '''ModeleBoxes'''.
However if you plan distributing your box to other users, you must create a module and store your box files inside your module.
* Go to [[Module development]] page to learn how to create a module
* Create your box file into '''htdocs/mymodule/core/boxes/'''
* Once your module descriptor is created, add these lines to declare your box file
<syntaxhighlight lang="PHP">
$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.
);
</syntaxhighlight>
* For distribution, package the module containing your box (See [[Module development]] page).


To create a new box, copy an existing box file and rename it.
= [[File:art.png]] Activate a widget =
Then change its content to match the new name and to define informations you want to show by the box.


However if you plan to distribute your box to other users, you should instead create a module and store your box files into you module:
To activate a box, go to '''Home - Setup - Boxes''' page and click activate on the box you want to see.
* Go into page [[Module Development]] to know how to create a module
* Copy the box file into '''htdocs/mymodule/core/boxes/'''
* Once you module descriptor is created, edit it to add lines to declare your box
<source lang="bash">
$this->boxes[0]['file'] = "box_file.php";
$this->boxes[0]['note'] = "My notes";
$this->boxes[0]['enabledbydefaulton'] = 1;
</source>


= [[File:art.png]] Activate a box =
It will be displayed on the page for which you have activated the box.
To activate a box, go on page '''Home - Setup - Boxes''' and click on activate on box you want to see. The page will appears on page for which you activate the box.

Latest revision as of 12:10, 23 September 2022

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

Boxes content is left to the developer's imagination (graphics, text, tables, …) but a basic framework allows for easy table based presentation.

Art.png Create a new Widget

Every standard box is stored inside the htdocs/core/boxes directory.

There is one file for each box.

Each file is a class inherited from the ModeleBoxes class.

To create a new box, you may copy an existing box file, rename it, for example to box_myownbox.php and change its content to match the new name.

You can now define the informations you want to show inside the box.

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

  • Go to Module development page to learn how to create a module
  • Create your box file into 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 widget

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.