Page 1 of 1
Problem converting code from old style code to new version code
Posted: Sat Apr 06, 2024 11:10 am
by 14Steve14
I am trying to update an older addon. I have the following line in an admin hook that creates a button in the customers page so that some customers details can be exported to csv. I have the page working as it should but this button code is causing an error. It is the tep bits that are causing the problem I believe. I have tried many things but still either get an error or a blank page.
Code: Select all
$parameters['contents'][] = ['text' => tep_draw_bootstrap_button(EXPORT_CUSTOMERS_NEWSLETTER, 'fas fa-file-export', tep_href_link('customers.php', 'preaction=export'), null, null, 'btn-warning btn-block')];
Is there anyone that can help get this button showing and working please.
Re: Problem converting code from old style code to new version code
Posted: Sat Apr 06, 2024 11:48 am
by raiwa
See my Google spreadsheet in my footer.
You could also just compare to a similar snippet in the core action:
Code: Select all
admin\includes\actions\customers\infoboxes\default.php
Re: Problem converting code from old style code to new version code
Posted: Sat Apr 06, 2024 1:59 pm
by ecartz
Code: Select all
$parameters['contents'][] = ['text' => $GLOBALS['Admin']->button(EXPORT_CUSTOMERS_NEWSLETTER, 'fas fa-file-export', 'btn-warning btn-block', $GLOBALS['Admin']->link('customers.php', ['preaction' => 'export']))];
Re: Problem converting code from old style code to new version code
Posted: Sat Apr 06, 2024 2:42 pm
by 14Steve14
Thanks to
@raiwa and
@ecartz .With a bit of guess work and copying from other files I got there.
The only problem I now have is that I am getting an error in my admin log files which is
[06-Apr-2024 15:22:05 Europe/London] PHP Warning: Constant ADMIN_EXPORT_CUSTOMERS_NEWSLETTER already defined in /home/###/public_html/####/includes/languages/english/hooks/admin/customers/MC.php on line 12
I have tried changing the name of the define/constant in the hook file and the language file and its still saying that ADMIN_EXPORT_CUSTOMERS_NEWSLETTER is already defined. Without the define in the language file the text is not present on the button. Removing the whole define from the language file creates a further error and stops the page loading.
I have search all the files and I cannot see another constant the same in this or my current website so have no idea where this message is coming from. How do I remove this error or at least find where the other define is.
Re: Problem converting code from old style code to new version code
Posted: Sat Apr 06, 2024 3:09 pm
by raiwa
Maybe you are including the language file manually in your hook?
Re: Problem converting code from old style code to new version code
Posted: Sat Apr 06, 2024 3:29 pm
by 14Steve14
raiwa wrote: ↑Sat Apr 06, 2024 3:09 pm
Maybe you are including the language file manually in your hook?
Just change the bit at the bottom that mentions the language file to one copied from another file and updates the location of the language file and all seems good again.
On to the next bit.
Thanks for your help.
Re: Problem converting code from old style code to new version code
Posted: Sat Apr 06, 2024 5:28 pm
by raiwa
You do not need to manually include the language file. Just name the language file identical like the hook. And place it in the language folder keeping the same directory structure like the hook. It will be auto loaded.
Re: Problem converting code from old style code to new version code
Posted: Tue Apr 09, 2024 1:44 pm
by 14Steve14
raiwa wrote: ↑Sat Apr 06, 2024 5:28 pm
You do not need to manually include the language file. Just name the language file identical like the hook. And place it in the language folder keeping the same directory structure like the hook. It will be auto loaded.
Thanks you very much. This coding is getting harder for someone like me that knows very little about it.
Re: Problem converting code from old style code to new version code
Posted: Sun Apr 14, 2024 3:07 pm
by Xpajun
14Steve14 wrote: ↑Tue Apr 09, 2024 1:44 pm
raiwa wrote: ↑Sat Apr 06, 2024 5:28 pm
You do not need to manually include the language file. Just name the language file identical like the hook. And place it in the language folder keeping the same directory structure like the hook. It will be auto loaded.
Thanks you very much. This coding is getting harder for someone like me that knows very little about it.
You know I'm sure once we get used to the changes and how to update them without getting errors I'm sure it will get easier
As I am equally sure that once we do find it easier some person will come along and change everthing to make it even harder
