What is the best to make plugin settings site specific? #16000
-
Let's say that i am creating integration with google analytics and i need setting which stores analytics ID that will be used. However, analytics ID should be different depending on which site is used. What would be best way to allow plugin users to set it up? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The easiest way would be to have them set the setting value from |
Beta Was this translation helpful? Give feedback.
-
@brandonkelly |
Beta Was this translation helpful? Give feedback.
The easiest way would be to have them set the setting value from
config/<plugin-handle.php>
, where they can set it to an array indexed by site handle. Then when you are fetching the value, run it throughcraft\helpers\ConfigHelper::localizedValue()
, which will check if it’s an array, and if so, only return the value for the current site.