With the country filter you can define which country your made
Configuration will be applied on.
'filter' => [
'country' => 'switzerland'
]
As SCP offers a lot of customization to you and your clients, we need some kind of mechanism to assign specific things to specific materials.
If you want to apply anything to a set of Materials you are required to play a little with our (currently) predefined Filters.
Filters define basically a set of business rules which will be validated against one or more Materials and once they match, the given logic behind them will be triggered.
Let's imagine you want to display the field notes for materials only which are built for Switzerland.
<?php
// CLIENT_CONFIG/config/fields.php
return [
'notes' => [
'field' => [
'label' => 'Some Notes',
'type' => 'textarea',
'filter' => [
'country' => 'switzerland'
]
]
],
];
Pretty simple, right?
The filter will be evaluated against the Meta Data of the current material and if the filter matches, the field is to be displayed.
Now, another request pops in: notes should only be available when the language is also german.
<?php
// CLIENT_CONFIG/config/fields.php
return [
'notes' => [
'field' => [
'label' => 'Some Notes',
'type' => 'textarea',
'filter' => [
'country' => 'switzerland',
'language' => 'german'
]
]
],
];
Well done! Still simple, right?
But whats about if notes should be displayed when the country is
switzerland or germany?
<?php
// CLIENT_CONFIG/config/fields.php
return [
'notes' => [
'field' => [
'label' => 'Some Notes',
'type' => 'textarea',
'filter' => [
'country' => ['switzerland', 'germany'],
'language' => 'german'
]
]
],
];
Also possible by just changing the value from a static value to an array of values.
If you want to let a filter match when something is not matching, just prepend the filtered key with an exclamation mark:
<?php
// CLIENT_CONFIG/config/fields.php
return [
'notes' => [
'field' => [
'label' => 'Some Notes',
'type' => 'textarea',
'filter' => [
'!country' => 'uk'
]
]
],
];
The above example will display the field notes whenever a material does not have UK set as its country.
For the remainder of this part of the documentation, we'll discuss each filter available. Remember, all of these filters can be chained to fluently manipulate the result.
Naming Conventions
Please do mind that there are no real naming convention in place, so the values available for any of the Meta Data filters in any Content Apps will probably differ. See their documentations for more insight.
Filter Selectors - Summarization
These two ways counts for the regular as well as the negating filters approach.
You can define a single one:
'filter' => [
'filter_key_1' => 'filter_value_1',
'!filter_key_2' => 'filter_value_2'
]
You can also define multiple countries via a flat array:
'filter' => [
'filter_key_1' => [
'filter_value_1a',
'filter_value_1b'
],
'!filter_key_2' => [
'filter_value_2a',
'filter_value_2b'
]
]
This documentation will follow the single line approach to save space as you will by now have gotten the gist of it.
Quick Links:
(tbd, pls sort via alphabet even though there is a world where CTRL+F exists (and Firefox' auto search feature))
countryWith the country filter you can define which country your made
Configuration will be applied on.
'filter' => [
'country' => 'switzerland'
]
languageWith the language filter you can define on which languages
your made Configuration will be applied on.
'filter' => [
'language' => 'french'
]
materialTypeWith the materialType filter you can define which Material Type
your made Configuration will be applied on.
'filter' => [
'materialType' => 'ae-template-flexi'
]
opuDeprecated since v7 the usage of the App Configuration.
If you are still using OPU as a field please update to Country for this.
'filter' => [
'opu' => 'switzerland'
]