Skip to main content
Version: 2024.4

Relations (Many-To-Many) Editable

General

The relations editable provides many to many relation to other Pimcore elements (document, asset, object).

Configuration

NameTypeDescription
widthintegerWidth for the widget in pixels (optional)
heightintegerHeight for the widget in pixels (optional)
titlestringTitle for the input-widget
uploadPathstringTarget path for (inline) uploaded assets
disableInlineUploadbooleanDisable the inline upload for assets. If set to true, the inline upload functionality will be disabled.
typesarrayAllowed types (document, asset, object), if empty all types are allowed
subtypesarrayAllowed subtypes grouped by type (folder, page, snippet, image, video, object, ...), if empty all subtypes are allowed (see example below)
classesarrayAllowed object class names, if empty all classes are allowed
classstringA CSS class that is added to the surrounding container of this element in editmode
reloadbooleantrue triggers page reload on each change

Methods

NameReturnDescription
getElements()arrayArray of the assigned elements
current()intGet the current index while looping
isEmpty()booleanWhether the editable is empty or not

Example

Basic Usage

The code below is responsible for showing a list of elements types related to the relations editable.

<p>{{ "Types of elements" | trans }}:</p>
{% if editmode %}
{{ pimcore_relations("objectPaths") }}
{% else %}
<ul>
{% for element in pimcore_relations("objectPaths") %}
<li>{{ element.getType() }}</li>
{% endfor %}
</ul>
{% endif %}

Picture below, presents the editmode preview:

Relations editable - editmode previewRelations editable - editmode previewRelations editable - editmode preview

The frontend part looks like that:

Relations editable - frontend previewRelations editable - frontend previewRelations editable - frontend preview

To better understand what exactly is the $element variable, have a look at the output below:

array(6) {
[0] => string(27) "Pimcore\Model\DataObject\Folder"
[1] => string(32) "Pimcore\Model\DataObject\BlogArticle"
[2] => string(32) "Pimcore\Model\DataObject\BlogArticle"
[3] => string(27) "Pimcore\Model\Document\Page"
[4] => string(27) "Pimcore\Model\Document\Page"
[5] => string(25) "Pimcore\Model\Asset\Image"
}

Example with allowed types and subtypes

Similar to the single relation editable, this editable also could specify allowed types, subtypes and classes. For example:

{{ pimcore_relations("objectPaths", {
"types": ["asset","object"],
"subtypes": {
"asset": ["video","image"],
"object": ["object"]
},
"classes": ["person"]
}) }}

Now, a user is not able to add other elements than specified in the types configuration part.