This module sets up variables in hook_install().

However, the usual pattern for variables is to code the default in the variable_get() call. Thus:

    'popup_info' => variable_get('eu_cookie_compliance_popup_info', 'DEFAULT VALUE HERE'),

Comments

Miszel’s picture

Status: Active » Postponed (maintainer needs more info)

The form where the HTML can be edited is multilingual and the variables change depending on the language. I hence decided to set it for English in the hook_install() so that there is at least one example. It may not be an ideal solution but what would work better? I can't have a copy for every language....

Besides, could you please explain why setting a variable in hook_install() is considered a bad practice?

Miszel’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)
joachim’s picture

> Besides, could you please explain why setting a variable in hook_install() is considered a bad practice?

It's just not the drupal pattern. You don't set a variable until the user has chosen to override it. It's not a perfect pattern, as it can sometimes mean you have to keep the default value in more than one place in code (and it's getting revamped for D8), but that's just the current pattern in D6 and D7 core and contrib. And with the current structure of your module, you're not subject to the problem of having the default in multiple places, so you might as well reduce your code anyway :)

Miszel’s picture

There are modules that set variables in the install file - for example path_auto. I do not set defaults in multiple places.