Is it possible to add a plugin configuration to an administration plugin and use it in a vue component or a corresponding twig template?
In the documentation I cannot find something about it. I have tried to use it in my template file like this {{ config('pluginName.config.inputFieldName') }}
but it doesn't work.
Use the systemConfigApiService
to fetch config values in Vue.js components:
Component.register('my-custom-component', {
template,
inject: ['systemConfigApiService'],
methods: {
async getPluginConfig() {
const response = await this.systemConfigApiService.getValues('YourPluginName.config', salesChannelId);
const inputFieldName = response['YourPluginName.config.inputFieldName'];
// ...
},
}
}
The sales channel id is optional. If omitted the fallback value for all sales channels will be given.