Back to topic list

Context modifiers

Context modifiers are very useful when building bricks. They modify all the context - every cms files based on some rules.

Example

say you have this context file:

{
    $deadline_type: 'date',
    deadline: '2019-01-01'
}

and you decided that all date controls in your project should be full-width(you can set width of admin control by $deadline_size: '12'). To do this, you can use context modifier add_sibling_to_type either in your app/app.js or in the brick you are building:

enduro.api.brick_processors.add_processor('cms_context_processor', function (cms_context) {
    return new Promise(function (resolve, reject) {

        enduro.api.context_modifiers.add_sibling_to_type(cms_context, 'date', 'size', 12)

        resolve(cms_context)
    })
})

List of modifiers

add_sibling_to_type

  • @param {cms context object} context
  • @param {string} type_to_search_for - will add siblings to all controls of this type
  • @param {string} added_termination - new termination key to add
  • @param {value} value - new value to add
Back to topic list

Shout out to pexels and freepik