Problem converting code from old style code to new version code

Open to all! Ask other shopowners for help.
Post Reply
14Steve14
Senior Contributor
Posts: 923
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Problem converting code from old style code to new version code

Post 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.


Join The Code Co-op to get access to your library in the Code Co-op Forum
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: Problem converting code from old style code to new version code

Post 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
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
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Problem converting code from old style code to new version code

Post 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']))];
14Steve14
Senior Contributor
Posts: 923
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: Problem converting code from old style code to new version code

Post 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.
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: Problem converting code from old style code to new version code

Post by raiwa »

Maybe you are including the language file manually in your hook?
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
14Steve14
Senior Contributor
Posts: 923
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: Problem converting code from old style code to new version code

Post 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.
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: Problem converting code from old style code to new version code

Post 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.
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
14Steve14
Senior Contributor
Posts: 923
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: Problem converting code from old style code to new version code

Post 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.
Xpajun
Contributor
Posts: 187
Joined: Thu Mar 04, 2021 1:18 pm
Phoenix Version: v1.0.9.0
Has thanked: 3 times
Been thanked: 6 times

Re: Problem converting code from old style code to new version code

Post 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 :D

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 :roll:
Current Store is now running 1.0.9.0 - php 8.2.18
Now working on taking a short rest :D - php 8.2.18


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