read_configuration.php without core change / defined variable change for debugging Hook / Overwrite

Open to all! Ask other shopowners for help.
Post Reply
loop
Contributor
Posts: 253
Joined: Thu Mar 25, 2021 12:26 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 3 times

read_configuration.php without core change / defined variable change for debugging Hook / Overwrite

Post by loop »

Hi All

I need a elegant solution without touching core code. i made a new configuration key for switching themes in my shop:HOMEPAGE_THEME_VARIANTS

I can choose from ['default','singles-day','cyber-monday','black-november','black-week','black-friday','xmas']

Everthing works good, and in includes/system/segments/application/read_configuration.php
it saves as HOMEPAGE_THEME_VARIANTS

The problem is i would like to change for "debugging" reason on the fly only for ME to a other theme, but as the HOMEPAGE_THEME_VARIANTS is already definied i cannot overwrite it...
of course i could do in the while a "if(!empty($get['theme']) " only thenn saves the configuration but it would be a hack...

is there a better solution to do this without changing includes/system/segments/application/read_configuration.php with a hook or worst case overwriting includes/system/segments/application/read_configuration.php with "ugly hack"?

Code: Select all

// set the application parameters
  $configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from configuration');
  while ($configuration = tep_db_fetch_array($configuration_query)) {
    define($configuration['cfgKey'], $configuration['cfgValue']);
  }

  //Test theme
$allowed_test_variants = ['default','singles-day','cyber-monday','black-november','black-week','black-friday','xmas'];
  if (!empty($_GET['theme']) && in_array($_GET['theme'], $allowed_test_variants, true)) {
    define('HOMEPAGE_THEME_VARIANTS', $_GET['theme']);
  }
Of course i could also do everywhere where i check HOMEPAGE_THEME_VARIANTS also for the $_GET variable but i don't want to do that if possible

Thanks


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4547
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: read_configuration.php without core change / defined variable change for debugging Hook / Overwrite

Post by burt »

If it's just for you, do it with a Hack. would suggest to put some sort of Key on it as well, where only you know the Key.
I am not here to build for you.
I am here to build with you. Let's help each other.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: read_configuration.php without core change / defined variable change for debugging Hook / Overwrite

Post by ecartz »

Copy read_configuration.php to a different name (same folder) and make your edits.
Edit the database hook that reads it https://github.com/CE-PhoenixCart/Phoen ... .sql#L1225
from 'hooks_method' 'read_configuration' to the new name (without .php which will be added automatically).

When you finish your debugging, edit the database hook hooks_method back to 'read_configuration' (the current name).
azpro
Contributor
Posts: 177
Joined: Fri Nov 06, 2020 8:25 am
Phoenix Version: v1.1.0.6
Has thanked: 30 times
Been thanked: 34 times

Re: read_configuration.php without core change / defined variable change for debugging Hook / Overwrite

Post by azpro »

Maybe you could use this Addon:
app.php/addons/free_addon/template_manager/

And adept with some life/test switch. I have it on my TODO list - so if you can report back? :D


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply