Renato Maretić
Renato Maretić

Reputation: 355

Shopware 6: How to Access Config Parameters in Twig Template of the Admin Module

I'm looking for a way to access configuration parameters in twig template of the admin module. I tried to access it by:

{{ shopware.config.pluginName.config.fieldName }}

The problem is that in the twig template of the admin module {{ shopware.config }} isn't available. I tried to access it by {{ dump(shopware.config) }} but it returns nothing. Am I doing something wrong?

Is there alternative to access plugin's configuration parameters in the admin module?

Is there a way to pass php variables to twig template of the admin module?

Thanks in advance,

Cheers!

Upvotes: 1

Views: 2396

Answers (2)

silkyland
silkyland

Reputation: 87

I found the solution to help you access global configuration via

{{ dump(config('core.listing.fieldName')) }}

Upvotes: 1

Valerio8787
Valerio8787

Reputation: 905

Try to use following service:

this.systemConfigApiService.getValues('domain', this.selectedSalesChannelId)

where domain is the Plugin name.

Of course, you should inject that service first

inject: ['systemConfigApiService']

Using that service you can provide config value to twig template.

Upvotes: 3

Related Questions