CategorySelector¶
CategorySelector element is a select list with categories.

Build-in Validators¶
Element validate if chosen category exists.
Available Validators¶
Element has available validators:
Relations Support¶
Element does not support relations between elements.
Configuration output schema¶
schema
{
"<element_type>" : "categorySelector",
"<element_name>" : string,
"<element_label>" : string,
"<element_labelDescription>" : string,
"<element_isRequired>" : bool,
"<element_isHidden>" : bool,
"<element_defaultValue>" : int,
"<element_validators>" : []
}
example
{
"type" : "categorySelector",
"name" : "category",
"label" : "Displayed category",
"isRequired" : false,
"isHidden" : false,
"defaultValue" : 12,
"validators": [
{
"type" : "lessEqThan",
"options" : { "max" : 25 }
}
]
}
Element value¶
If value is filled: int.
usage in module TWIG
{% if moduleConfig.category %}
Displayed category ID: {{ moduleConfig.category }}
{% endif %}
Example of module¶
Twig¶
Twig
{% set categoryId = moduleConfig.selectedCategoryId %}
{% set category = ObjectApi.getCategory(categoryId) %}
{% if category %}
<section>
<div>
<h2 class="h2">{{ category.name }}</h2>
{% if moduleConfig.showDescription and category.description %}
<p>
{{ category.description|raw }}
</p>
{% endif %}
<div>
<a href="{{ category.url }}" class="btn btn_primary">
{{ translate("See products") }}
</a>
</div>
</div>
</section>
{% endif %}
JSON configuration¶
JSON configuration
[
{
"label": "Category",
"state": "unfolded",
"elements": [
{
"name": "selectedCategoryId",
"type": "categorySelector",
"label": "Select Category"
},
{
"name": "showDescription",
"type": "checkbox",
"label": "Show category description"
}
]
}
]
JSON translations¶
JSON translations
{
"module": {
"pl_PL": {
"See products": "Zobacz produkty"
},
"en_US": {
"See products": "See products"
}
},
"schema": {
"pl_PL": {
"Category" : "Kategoria",
"Show category description" : "Pokaż opis kategorii"
},
"en_US": {
"Category" : "Category",
"Show category description" : "Show category description"
}
}
}