I was following this article here: https://u.expressionengine.com/article/custom-global-variables-using-the-config-file
But it does not see me to work for me.
I added the example code in: /expressionengine/user/config.php
Then tried a variable, but I just get the variable printed in my template, such as:
{global:some_api_key}
Instead of the actual value.
You might need to add this at the beginning:
global $assign_to_config;
I’m not sure if the global part is required, but it’s what I have in one particular environment.
The final code in your config.php file would look like this
global $assign_to_config;
$default_global_vars = [
'global:disabled_params' => 'disable="trackbacks|pagination|member_data"',
'global:disabled_params_all' => 'disable="trackbacks|pagination|member_data|category_fields|categories|custom_fields"',
'global:disabled_params_strict' => 'disable="trackbacks|pagination|member_data|category_fields|categories"',
'global:blog_category_groups' => '2|3|5|6',
'global:some_api_key' => '98ufahaskdfnasd312',
];
if (!isset($assign_to_config['global_vars'])) {
$assign_to_config['global_vars'] = [];
}
$assign_to_config['global_vars'] = array_merge(
$default_global_vars,
$assign_to_config['global_vars']
);
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.