Accordion
in package
Accordion class for creating HTML accordions.
Tags
Table of Contents
- $datas : mixed
- Array of accordion items.
- $id : mixed
- ID of the accordion. Must be unique.
- $type : mixed
- Type of accordion (radio or checkbox).
- __construct() : mixed
- Constructor.
- add() : mixed
- Add an item to the accordion.
- render() : string
- Generate the HTML code for the accordion.
Properties
$datas
Array of accordion items.
private
mixed
$datas
$id
ID of the accordion. Must be unique.
private
mixed
$id
$type
Type of accordion (radio or checkbox).
private
mixed
$type
Methods
__construct()
Constructor.
public
__construct(string $id[, array<string|int, mixed> $items = [] ][, bool $onetab = false ]) : mixed
Parameters
- $id : string
-
ID of the accordion (must be unique).
- $items : array<string|int, mixed> = []
-
Initial items array (array(array('title1' => 'detail1'), array('title2' => 'detail2'))).
- $onetab : bool = false
-
true to allow opening only one tab at a time, false (default) to allow opening and closing tabs independently.
Return values
mixed —add()
Add an item to the accordion.
public
add(string $title, string $detail[, bool $select = false ][, string $className = 'article' ]) : mixed
Parameters
- $title : string
-
Title of the item.
- $detail : string
-
Details of the item.
- $select : bool = false
-
true to display this item, false (default) otherwise.
- $className : string = 'article'
-
CSS class for the item's content container. Use "article" as default if not specified.
Return values
mixed —render()
Generate the HTML code for the accordion.
public
render() : string
Return values
string —HTML code for the accordion.