Widget system: Difference between revisions

Jump to navigation Jump to search
m
Sync with french
m (Sync with french)
Line 2: Line 2:
{{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 (like the home page). These are described using files in a specific directory.


Content of such boxes is only limited vy developer imagination (graphics, text, tables, ...).
Boxes content is left to the developer's imagination (graphics, text, tables, …).




Line 13: Line 13:
There is one file for each box.
There is one file for each box.


Each file is a PHP class that inherits the class '''ModeleBoxes'''.
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 into '''box_myownbox.php'''.
To create a new box, copy an existing box file and rename it, for example to '''box_myownbox.php'''.
Then change its content to match the new name and define informations you want to show through the box.
Change its content to match the new name and define informations you want to show inside 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 your module:
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 into page [[Module development]] to know how to create a module
* Go to [[Module development]] page to learn how to create a module
* Copy the box file into '''htdocs/mymodule/core/boxes/'''
* Copy the box file to '''htdocs/mymodule/core/boxes/'''
* Once your module descriptor is created, edit it to add lines to declare your box
* Once your module descriptor is created, add these lines to declare your box file
<source lang="bash">
<source lang="php">
$this->boxes[0]['file'] = "box_myownbox.php";
$this->boxes = array(
$this->boxes[0]['note'] = "My notes";
    0 => array(
$this->boxes[0]['enabledbydefaulton'] = 1;
        'file' => 'box_myownbox@mymodule',
        'note' => 'My notes',
        'enabledbydefaulton' => 'Home'
    )
    // You can declare as much boxes as you want by simply incrementing the index.
);
</source>
</source>
* Create a package to distribute your module containing your box (See page [[Module development]]).
* For distribution, package the module containing your box (See [[Module development]] page).


= [[File:art.png]] Activate a box =
= [[File:art.png]] Activate a box =
To activate a box, go on page '''Home - Setup - Boxes''' and click on activate on box you want to see. The page will appear on page for which you have activated the 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.
Bureaucrats, emailconfirmed, Administrators
149

edits

Navigation menu