How to Change an Admin File.
- Portman
- VIP Member
- Posts: 130
- Joined: Mon Mar 08, 2021 1:04 am
- Has thanked: 29 times
- Been thanked: 4 times
How to Change an Admin File.
Hello Again,
Hopefully a quick one here...
If I want to modify an Admin file but don't want to change the core code, where do I save it?
I made a minor change to admin/includes/modules/currencies/c_ecb.php so that it gets the inverse exchange rate (there is a perfectly good reason for this).
I then saved it in templates/override/admin/includes/modules/currencies/c_ecb.php
I assumed this was wrong but wanted to try for myself first - I was right it did not work.
Is there a way to do this?
Thanks for any help
Hopefully a quick one here...
If I want to modify an Admin file but don't want to change the core code, where do I save it?
I made a minor change to admin/includes/modules/currencies/c_ecb.php so that it gets the inverse exchange rate (there is a perfectly good reason for this).
I then saved it in templates/override/admin/includes/modules/currencies/c_ecb.php
I assumed this was wrong but wanted to try for myself first - I was right it did not work.
Is there a way to do this?
Thanks for any help
-
- PhoenixCart Developer
- Posts: 1339
- Joined: Sat Dec 21, 2019 8:08 am
- : Buy Me A Beverage
- Has thanked: 39 times
- Been thanked: 108 times
Re: How to Change an Admin File.
Admin files and modules can’t be overridden in the template. You may use a renamed copy of the original file.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
-
- Lead Developer
- Posts: 2770
- Joined: Tue Oct 29, 2019 9:37 am
- : Buy Me A Beverage
- Has thanked: 52 times
- Been thanked: 157 times
Re: How to Change an Admin File.
As per raiwa's advice above, you'd make yourself a new currency module (copying most of c_ecb) and set that to be used as the currency converter.
Admin > Modules > Update Currencies > {install}
and
Admin > Localization > Currencies
The idea behind "module" is that you don't use [turn off] the core one, and instead use one you've made yourself or had made or found in the addons area etc. That's true for all modules, not just currencies.
Admin > Modules > Update Currencies > {install}
and
Admin > Localization > Currencies
The idea behind "module" is that you don't use [turn off] the core one, and instead use one you've made yourself or had made or found in the addons area etc. That's true for all modules, not just currencies.
Current Beer Fund: £11.53
#wearephoenix #wearecommunity
#wearephoenix #wearecommunity
- Portman
- VIP Member
- Posts: 130
- Joined: Mon Mar 08, 2021 1:04 am
- Has thanked: 29 times
- Been thanked: 4 times
Re: How to Change an Admin File.
im trying to apply what you suggested, what am i doing wrong?
Im getting the error....
PHP Fatal error: Cannot declare class c_ecb, because the name is already in use in .... /admin/includes/modules/currencies/inv_currency.php on line 70
Im getting the error....
PHP Fatal error: Cannot declare class c_ecb, because the name is already in use in .... /admin/includes/modules/currencies/inv_currency.php on line 70
Code: Select all
class inv_currency extends abstract_module {
const CONFIG_KEY_BASE = 'MODULE_ADMIN_CURRENCIES_INV_CURRENCY_';
public static function execute() {
$xml = Web::load_xml('https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml');
$xml = json_decode(json_encode($xml), JSON_FORCE_OBJECT);
$currency_query = $GLOBALS['db']->query("SELECT currencies_id, code, title FROM currencies");
while ($currency = $currency_query->fetch_assoc()) {
$to[$currency['code']] = $currency['code'];
}
$from = DEFAULT_CURRENCY;
$ecb_currencies = ['EUR' => 1.0];
foreach ($xml as $a) {
foreach ($a['Cube']['Cube'] as $b) {
$ecb_currencies[$b['@attributes']['currency']] = $b['@attributes']['rate'];
}
}
if ($from !== 'EUR') {
$exchange = $ecb_currencies[$from];
foreach ($ecb_currencies as $x => $y) {
$ecb_currencies[$x] = $y/$exchange;
}
}
$to_exchange = array_intersect_key($ecb_currencies, $to);
foreach ($to_exchange as $k => $v) {
$invrate = 1/$v; //Added by Portman - to get inverse exchange rate
// $rate = Text::input($v);
$rate = Text::input($invrate); // Mod by Portman
$GLOBALS['db']->query("UPDATE currencies SET value = '" . $GLOBALS['db']->escape($rate) . "', last_updated = NOW() WHERE code = '" . $GLOBALS['db']->escape($k) . "'");
$GLOBALS['messageStack']->add_session(sprintf(MODULE_ADMIN_CURRENCIES_INV_CURRENCY_CURRENCIES_UPDATED, $k), 'success');
}
}
protected function get_parameters() {
return [
'MODULE_ADMIN_CURRENCIES_INV_CURRENCY_STATUS' => [
'title' => 'Enable INVERSE CURRENCY Module',
'value' => 'True',
'desc' => 'Do you want to install this Currency Conversion Module?',
'set_func' => "Config::select_one(['True', 'False'], ",
],
'MODULE_ADMIN_CURRENCIES_INV_CURRENCY_SORT_ORDER' => [
'title' => 'Sort Order',
'value' => '0',
'desc' => 'Sort order of display. Lowest is displayed first.',
],
];
}
}
- bonbec
- VIP Member
- Posts: 65
- Joined: Mon Oct 26, 2020 12:23 pm
- Has thanked: 10 times
- Been thanked: 7 times
Re: How to Change an Admin File.
Hi,
Take a look here : https://phoenixcart.org/phoenixcartwiki ... ent_Module
Take a look here : https://phoenixcart.org/phoenixcartwiki ... ent_Module
Old MS2.2 PHP7.4 site being converted to CE Phoenix v1.0.9.6 PHP 8.3
-
- PhoenixCart Developer
- Posts: 1339
- Joined: Sat Dec 21, 2019 8:08 am
- : Buy Me A Beverage
- Has thanked: 39 times
- Been thanked: 108 times
Re: How to Change an Admin File.
In the original module line 70 is the last line and empty.
What do you have in your module in line 70?
What do you have in your module in line 70?
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
- Portman
- VIP Member
- Posts: 130
- Joined: Mon Mar 08, 2021 1:04 am
- Has thanked: 29 times
- Been thanked: 4 times
Re: How to Change an Admin File.
Line 70 is the closing }
I have only changed a couple of lines to create an inverse exchange rate
- Portman
- VIP Member
- Posts: 130
- Joined: Mon Mar 08, 2021 1:04 am
- Has thanked: 29 times
- Been thanked: 4 times
Re: How to Change an Admin File.
Thanks, I feel like I have followed these instructions...bonbec wrote: ↑Tue Sep 26, 2023 7:06 am Hi,
Take a look here : https://phoenixcart.org/phoenixcartwiki ... ent_Module
I have modified admin/includes/modules/c_ecb.php which does not have a corresponding template page
I have changed the class name from c_ebc to inv_currency and changed every instance of CURRENCIES_EBC to INV_CURRENCY...
As far as I can tell I've done what I need to but I must be missing something
-
- VIP Member
- Posts: 2190
- Joined: Mon Oct 07, 2019 4:39 am
- : Buy Me A Beverage
- Has thanked: 30 times
- Been thanked: 203 times
Re: How to Change an Admin File.
We have no answer but the error message seems strange as there's no mention of c_ecb in the code that you posted.
Can only advise to repeat your work from scratch and upload again, then ensure the old module is uninstalled before installing the new. Maybe also double check your configuration table in your database to ensure the old module is uninstalled but just guessing.