Parameters API
This is a technical summary of what is offered by our Parameters API and how to create your own Managed Parameters within Cornerstone.
Create a Custom Managed Parameter
@since Cornerstone 7.5.4
Use the function cs_parameters_managed_register
to create your own parameter type. This uses the filter cs_parameters_managed
internally. Argument one is the type
you will reference in your parameters JSON. Argument 2 is the parameter data.
// Custom managed parameter
// This is the same as the `text-align` parameter type
cs_parameters_managed_register('managed-test', [
'type' => 'choose',
'initial' => 'none',
'offValue' => 'none',
'options' => [
[ 'value' => 'left', 'icon' => 'ui:text-align-left' ],
[ 'value' => 'center', 'icon' => 'ui:text-align-center' ],
[ 'value' => 'right', 'icon' => 'ui:text-align-right' ],
[ 'value' => 'justify', 'icon' => 'ui:text-align-justify' ],
],
]);
Then in your parameters in Cornerstone you would reference it by the type
you set in the function which was managed-test
in our example.
{
"managedTest": {
"type": "managed-test"
}
}
Grab All Managed Parameters
Use the function cs_parameters_managed
to grab all managed parameters. Cornerstone uses this function interally.
$managedParameters = cs_parameters_managed();
See something inaccurate? Let us know