-
Notifications
You must be signed in to change notification settings - Fork 118
Adding new JS global variables
Andy Mc edited this page Jun 24, 2021
·
1 revision
To add a new JS global variable that is available on every CP page:
- Edit
/system/ee/legacy/libraries/Cp.php
- Locate the
set_default_view_variables()
method - Add your JS variable to the code that starts with
ee()->javascript->set_global(array(
- Reference your variable with the EE prefix:
EE.cp.jumpMenuURL
ee()->javascript->set_global(array(
'BASE' => str_replace(AMP, '&', BASE),
'XID' => CSRF_TOKEN,
'CSRF_TOKEN' => CSRF_TOKEN,
'PATH_CP_GBL_IMG' => PATH_CP_GBL_IMG,
'CP_SIDEBAR_STATE' => ee()->session->userdata('show_sidebar'),
'username' => ee()->session->userdata('username'),
'router_class' => ee()->router->class, // advanced css
'lang' => $js_lang_keys,
'THEME_URL' => $this->cp_theme_url,
'hasRememberMe' => (bool) ee()->remember->exists(),
'cp.updateCheckURL' => ee('CP/URL', 'settings/general/version-check')->compile(),
'cp.jumpMenuURL' => ee('CP/URL', 'jumps')->compile(),
));