Skip to content

ContentType

ContentType contain the structure, default environment and information for all related revisions.

Properties

PropertyDescription
nameInternal name
pluralNameDisplay plural name
singularNameDisplay single name
iconDisplay icon in menu, dropdown, revision
colorDisplay color
descriptionInternal description (not visible for users)
indexTwigDeprecated
extra
askForOuuid
refererFieldName
sortOrder
rootContentType
editTwigWithWysiwyg
webContent
autoPublish
active
environment
defaultValueSee Default value
versionTags
versionOptions
versionDateFromField
versionDateToField
rolesJson field see roles
fieldsJson field see fields
settingsSee settings

Default value

On a content type you can define a default value for the revisions. The result should be a valid JSON rendered by Twig template.

Template context

  • environment : the default environment of the content type
  • contentType : the content type entity
  • currentUser : the authenticated user

Fields

On a content type we can define fields from the elasticsearch mapping. These are used for displaying revision information.

FieldDescription
displayExpression for display the revision using emsco_display
labelDisplay label for the revision
colorDisplay color for the revision
sortDefault sorting in choice lists (better use querySearch)
tooltipAdd tooltip on dataLinks
circlesField containing the revision circles
business_idUsed in export/import documents
categoryUsed in criteria view
assetUsed in asset link from WYSIWYG

Settings

SettingDescription
Task enabledsee [#Tasks]
Hide revision sidebarIf enabled will not show the sidebar

Tasks

When tasks are enabled, every user can create, handle, validate tasks inside a revision.

If a user completes a task, he can only validate the task if he is the requester.

Only the requester and task admins can delete the tasks

On all tasks steps the assignee and/or requester will receive emails.

Users who have the role TASK_MANAGER can see all current tasks in their dashboard overview.

Task admins can also delete tasks, but the requester will receive an email.

Roles

On a content type you can define a user role for permissions.

PermissionDescription
viewDisplay contentType in menu, enable dataLinks
createGrant creation of new revisions
editGrant update revision
publishGrant publication to other environments, can be overruled by environment publish role
deleteGrant delete revision
trashTrash functional enabled (put back deleted revisions)
archiveGrant archive revision (unpublish default environment)
ownerCan be revision owners
show_link_createDisplay creation link in navigation
show_link_searchDisplay search link in navigation

Actions

Render optiondescription
EmbedCreate a custom action page
ExportCreate an export file (csv, xml, ..)
External linkCreate an external link
RawHTMLCustom raw html action
NotificationCreate a new notification
JobStart a new job
PDFGenerate a pdf

Embed

The body is used for creating a new page. Good for generating overviews or custom reports.

Export

Export a generated file.

Spreadsheet

If you enable the spreadsheet checkbox, the body needs to return a valid json. This json is passed to the common Spreadsheet generator.

  • mimetype can be left empty, because it will be set by the spreadsheet generator.
  • extension is required and can be csv or xlsx

If you use the csv extension the body can only contain one sheet.

Example export
twig
{{- [
    {
        "name": "sheet1",
        "rows": [
            ["bundle", "description"],
            ["core-bundle", "symfony core bundle"],
            ["common-bundle", "symfony common bundle"]
        ]
    }
]|json_encode|raw -}}
Example export jsonMenuNested

Export the nested object fields title_nl, title_fr, date_start, date_end from the field named items.

twig
{%- set columns = ['title_nl', 'title_fr', 'date_start', 'date_end'] -%}
{%- set rows = [] -%}
{%- set rows = rows|merge([columns]) -%}
{%- set codes = source.items|default('[]')|ems_json_menu_nested_decode -%}
{%- for item in items.children -%}
    {%- set row = [] -%}
    {%- for column in columns -%}
        {%- if column in ['date_start', 'date_end'] -%}
            {%- set objectDate = attribute(item.object, column)|default(false) -%}
            {%- set row = row|merge([ objectDate ? objectDate|date('d-m-Y') : '' ]) -%}
        {%- else -%}
            {%- set row = row|merge([ attribute(item.object, column)|default('') ]) -%}
        {%- endif -%}
    {%- endfor -%}
    {%- set rows = rows|merge([row]) -%}
{%- endfor -%}
{{- [ { "name": "export jsonMenuNested", "rows": (rows) }]|json_encode|raw -}}

Import

This actions shows a modal with a file upload field, only allowing xlsx or csv files. On submit the data is parsed and imported in the default environment.

For the moment we only support jsonMenuNested import data. Generated by the export action for example.

The body template requires a block name config which outputs a valid json and defining the following:

  • type: jsonMenuNested
  • field: target import field name
  • columns: required column names

Passing an empty or invalid file, will result in error messages inside the modal.

For importing a jsonMenuNested we should build the object. This is done by defining a block named row, which outputs a valid json.

Example import jsonMenuNested

twig
{%- block config -%}
{{- {
    type: 'jsonMenuNested',
    field: 'items',
    columns: ['title_nl', 'title_fr', 'date_start', 'date_end']
}|json_encode|raw -}}
{%- endblock -%}

{%- block row -%}
{%- set label = [row.title_nl, row.title_fr]|join(' / ') -%}
{{- {
    id: ems_uuid(),
    label: (label),
    type: 'item',
    object: (row|merge({
        date_start: (row.date_start|default(false) ? row.date_start|date(constant('\DateTime::ATOM')) : null),
        date_end: (row.date_end|default(false) ? row.date_end|date(constant('\DateTime::ATOM')) : null)
    }))
}|json_encode|raw }}
{%- endblock -%}

The body is the href attribute for the external link. You can also use the raw render option for more flexibility.

Raw HTML

Only if the body returns html the output will be visible. With the HTML render option you can even overwrite the icon.

Notification

Creates a new ems notification

Job

Start a new job, the body should be the command with arguments and options.

Pdf

Similar to the export render option, but will always generate a pdf.

Transformers

In the "Migration Options" of contenttype field you can add one or more transformers. For each transformer you need to define a JSON config. When running the transform command these transformers will be applied.

NameDescriptionField
Html Attribute TransformerRemove html attribute or remove attribute values.wysiwyg
Html Empty TransformerClean empty html contentwysiwyg
Html Remove Node TransformerClean empty html contentwysiwyg

#Html Attribute Transformer

Only available for WYSIWYG field types.

Config

  • attribute : required, which attribute you want to transform
  • element : default (*), which html element
  • remove : default (false), remove the attribute
  • remove_value_prefix : default (null), remove all values starting by from class or style attributes.

Examples

Remove all style attributes for all table elements

json
{ "attribute": "style", "element": "table", "remove": "true" }

Remove all cellpadding attributes for all table elements

json
{ "attribute": "cellpadding", "element": "table", "remove": "true" }

Remove all style values related to font-size

json
{ "attribute": "style", "element": "*", "remove_value_prefix": "font-size" }

Remove all class values starting with 'font' from all divs

json
{ "attribute": "class", "element": "div", "remove_value_prefix": "font-" }

Html Empty Transformer

Only available for WYSIWYG field types. Clean content without textual content

No config required

Example transformer to null

html
<p style="text-align: justify;"></p>
<div class="example" style="text-align: justify;"></div>
<p></p>
html
<html lang="en">
    <body>
        <h1></h1>
        <p>&nbsp;</p>
    </body>
</html>

Html remove node transformer

Remove all span elements

json
{ "element": "span" }

Remove all span that have a class attribute containing delete

json
{ "element": "span", "attribute": "class", "attribute_contains": "delete" }

Views

NameDescription
CalendarViewTypeA view where you can schedule your object
CriteriaViewTypeA view where we can massively edit content types having criteria
DataLinkViewTypeManipulate the choices in a data link of this content type
ExportViewTypePerform an elasticsearch query and generate a export with a twig template
GalleryViewTypeA view where you can browse images
HierarchicalViewTypeManage a menu structure (based on a ES query)
ImporterViewTypeForm to import a zip file containing JSON files
KeywordsViewTypeA view where all properties of kind (such as keyword) are listed on a single page
ReportViewTypePerform an elasticsearch query and generate a report with a twig template
SorterViewTypeOrder a sub set (based on a ES query)

Calendar view

A view where you can schedule your object

Criteria view

A view where we can massively edit content types having criteria

Manipulate the choices in a data link of this content type.

It is used by the searchApi when creating an internal link inside a WYSIWYG. The view template does not need to return anything, it needs to add data to the passed dataLinks object. This view will be excluded from the elasticms menu navigation.

Twig content template

NameInstance
viewEntity\View
contentTypeEntity\contentType
environmentEntity\environment
dataLinksCore\Document\DataLinks

Example

A document contains a json menu nested structure, and you want to select a node (id) inside this structure. The WYSIWYG has a language defined and is also passed to the twig context.

twig
{% set searchStructures = {
    "index": environment.alias,
    "size": 50,
    "body": {
        "query": { "bool": { "must":[ {"term": { "_contenttype": {"value":"my_structure"} } } ] } },
        "sort": [ { "order": { "order": "asc" } } ]
    }
}|search.hits.hits %}

{% set structures = [] %}
{% for h in searchStructures %}
    {% set structures = structures|merge([{
        'id': h._id,
        'type': 'structure',
        'label': (h._source.label),
        'object': { "label": (h._source.name) },
        'children': (h._source.structure|default('{}')|ems_json_decode)
    }]) %}
{% endfor %}
{%- set structureMenu = structures|json_encode|ems_json_menu_nested_decode -%}

{% set locale = dataLinks.locale|default('fr') %}

{% set patterns = dataLinks.pattern|split('>')|map(v => v|trim) %}
{% set pattern = patterns|join('.*') %} {# searching for "Example > link" will patch "This Example > test > test2 > link" #}
{% set matchRegex = "/.*#{pattern}.*/i"  %}

{% for item in structureMenu %}
    {% set path = [] %}
    {%- for p in item.path -%}{%- set path = path|merge([p.object.label]) -%}{%- endfor -%}

    {% set text = path|join(' > ') %}
    {% if text matches matchRegex %}{% do dataLinks.add( ("my_node:#{item.id}"), text ) %}{% endif %}
{% endfor %}

Export view

Perform an elasticsearch query and generate a export with a twig template

A view where you can browse images

Hierarchical view

Manage a menu structure (based on a ES query)

Importer view

Form to import a zip file containing JSON files

Keywords view

A view where all properties of kind (such as keyword) are listed on a single page

Report view

Perform an elasticsearch query and generate a report with a twig template

Sorter view

Order a sub set (based on a ES query)