Reusable components¶
When you extend the Back Office, you can use base Twig templates for commonly used UI components such as tables or tabs.
The available templates are:
@ibexadesign/ui/component/alert/alert.html.twig
@ibexadesign/ui/component/table/table.html.twig
@ibexadesign/ui/component/tab/tabs.html.twig
To use the components, embed
them in templates.
With embed
you can override blocks that are defined inside the included template.
Alerts¶
The alert component has the following properties:
type
- available types of alert: error, info, success and warningicon
- name of the icon, taken from the default icon seticon_path
- full icon path, in case you do not want to use an icon from the default icon settitle
- alert titlesubtitle
- displays subtitle contentshow_subtitle_below
- default set tofalse
, the subtitle is displayed next to the titleextra_content
- use to add custom elements, such as buttons or additional textshow_close_btn
- by default set tofalse
, if set totrue
, the Close button is displayed but requires additional JavaScript configuration on your side to workis_toast
- default set tofalse
, applies the toast designclass
- additional CSS classesattributes
- additional HTML attributes
1 2 3 4 5 6 7 8 |
|
Details¶
The details component consists of the following blocks:
details_header
details_items
Variables:
Name | Type | Values |
---|---|---|
headline (optional) |
string | if not specified, the header is not rendered |
headline_items |
array | |
view_mode |
string | vertical , default set to '' |
items |
hash | {label , content_raw , content } |
If headline
is not specified, the headline_items
is not rendered.
Modal¶
The modal component consists of the following blocks:
1 2 3 4 5 6 7 8 |
|
Variables:
Name | Type | Values |
---|---|---|
size |
string | small , large , extra-large , default set to: '' |
subtitle |
string | no default value, if not defined, the subheader is not rendered |
no_header |
boolean | default set to false |
no_header_border |
boolean | default set to false |
class |
string | default '' |
id |
string | |
has_static_backdrop |
boolean | default set to false |
attr
and other attr_*
hold all HTML attributes rendered on their respective elements.
attr
Name | Type | Values |
---|---|---|
class |
string | default '' |
role |
string | default dialog |
tabindex |
string | default -1 |
attr_dialog
Name | Type | Values |
---|---|---|
class |
string | default set to '' |
role |
string | default set to document |
attr_content
Name | Type | Values |
---|---|---|
class |
string | default set to '' |
attr_title
Name | Type | Values |
---|---|---|
class |
string | default set to '' |
attr_close_btn
Name | Type | Values |
---|---|---|
class |
string | default set to '' |
type |
string | default set to button |
title |
string | default set to Close |
Tables¶
The table component consists of the following blocks:
header
- headline for the table sectionheadline
- table nameactions
- action buttons, for example, create, bulk deletetable
- the table itselfthead
- table header contenttbody
- table body content
Override specific cell¶
For the twig
table component to have full control over rendering the rows of specific cells, only data are passed to it.
Data rows are passed in an array - one row per one array element.
It is necessary to put objects with the columns data in an array.
There are a few types of table columns:
- normal content column -
{ content: col_name }
- a column icon -
{ has_icon: true, content: col_icon }
- a checkbox column -
{ has_checkbox: true, content: col_checkbox }
- action buttons column -
{ has_action_btns: true, content: col_action_btns }
Each column has the raw
parameter which prevents the component from the escaping content (untrusted user-generated content).
If you want to create an array based on some data from the backend, create an empty array and fill it with items (which corresponds to table rows) inside for loop:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Render hyperlink¶
The following example shows how to render both text and hyperlink which redirect to the specified content.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
Actions¶
See the example below to learn how to create an action button which removes the article in the table. The table component has to be wrapped into the remove article form.
As in many cases you want a button to be disabled when no item in a table is selected and enabled otherwise, there is a built-in mechanism for this.
To enable it you need to add the ibexa-toggle-btn-state
CSS class to the form element alongside data-toggle-button-id
data-attribute
which holds the id of the button that should be enabled/disabled after a checkbox state change.
Next, pass a button under the action
parameter to the table headline.
Action buttons are rendered on the right side of the table headline (do not confuse it with the table header).
You can also specify headline text, which is a table title displayed above, by passing it under headline
parameter.
You can generate various headline texts using the results_headline
macro with a few parameters:
count
- of all results, not only displayed on the first pagehas_filters
- when using filtersphrase
- filtering phraseresults_headline
- ensures the headlines consistency across the platformhead_cols
- an array for table header (not headline), corresponds with consecutive column
Column types available for the table header :
- normal content column
{ content: col_name }
(content is the title of the column) - icon column
{ has_icon: true }
- checkbox column
{ has_checkbox: true }
- action buttons column
{ }
Additional parameters available for all of the objects mentioned earlier:
1 2 |
|
See the example:
1 2 3 4 5 6 |
|
empty_table_info_text
andempty_table_action_text
specify texts which are displayed when the table is empty.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
Other table component parameters include:
class
- (CSS table class)attr
- (other HTML attributes applied on the HTML table element), for example:attr: { 'data-some-data-attribute-you-need': 'foo' }
table_body_class
andtable_body_attr
are the same as mentioned earlier, but applied on the table elementshow_head_cols_if_empty
- (default:false
), by default, whenbody_rows
is empty, the table component does not show the table header, but you may want to have it because for example rows are rendered dynamically with JavaScript on the browser side.
To avoid wrapping headline inside the form, as it's done in the earlier example, you can embed
table and override the between_header_and_table
block:
1 2 3 4 5 6 |
|
This method is useful in case of another form inside headline actions or to avoid interferences with the form like button triggering its submission.
Tip
For an example of using the table component, see Add menu item.
Tabs¶
The tab component consists of the following block:
tab_content
- tab content
The tab component supports the following variables:
tabs
id
- tab IDlabel
- human-readable label for the tabactive
- true if tab is activecontent
- HTML content of tab iftab_content
is not overriddentab_content_class
- additional CSS classes attached to.tab-content
tab_content_attributes
- additional HTML attributes added to.tab-content
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
With tabs, you can use include
instead of embed
when you pass tab content as a variable while rendering the template:
1 2 3 4 5 6 |
|