Best practice to replace Admin module(s)

Recommended Posts

I am working on an add-on that expands the functionality of one (or more) of the stock, built-in ADMIN modules, and it involves adding additional fields to the existing databases. Since ADMIN is not modular (yet), I can't just un-install the stock module(s). So, I can either:

1) Overwrite the stock modules (clearly not the best choice),

or2) Give the new modules different names, and just add the new module name(s) to the menu structure. But, this would leave the original modules intact and still in the menu structure, where:

a) the original module may not functional any more, or worse,

b) they may actually mess up the newly expanded database tables.

or3) Add the new module names to the menu structure, and try to figure out a way to remove the original module names from the menu structure (and add them back if the new module is ever removed).

I have seen examples of how to add a menu item, but not how to remove a stock one (without editing the 'core' menu definition files (I suppose I could just replace the stock menu definition files, and put the original ones back if uninstalling. But, that could mess up someone that had already hand edited their menu definitions)). Can someone point me toward a Best Practice way to do this?

TIA

Malcolm

If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get the latest community-supported responsive "Frozen" release here

Share this post

Link to post

Share on other sites

Let's say that I want to add additional fields to the 'countries' table. And, to be able to administer these new fields, I will want to make changes to /admin/countries.php (a core file). To change this file, I could overwrite the stock /admin/countries.php file. Not the best choice, in my opinion.

Even in Frozen, the stock ADMIN menus are still hard coded (in this case, the link to /admin/countries.php is in /admin/includes/boxes/localization.php).

So, instead of overwriting /admin/countries.php, let's say that I call my new admin file something like /admin/new_countries.php. I can add a link to my new file to the menu (I have seen how to add a new menu item to the array), but the stock link to the stock /admin/countries.php file would still be in the menu. I'm concerned that a shop owner (or some hired help) might use the stock /admin/countries.php link and file, and possibly mess up the database table.

I could overwrite the /admin/includes/boxes/localization.php file, but there's the chance that the store owner has already made their own changes to /admin/includes/boxes/localization.php, so overwriting it would also not be a good choice.

What I originally asked was ... is there a way THROUGH THE ADD-ON INSTALLATION process, to be able to remove (or hide) a link in /admin/includes/boxes/localization.php menu file, and be able to add it back (or un-hide it) if the add-on is ever uninstalled?

After some additional thought, though, I might have a better solution. During the add-on installation, I could:

1) rename the stock /admin/countries.php file to something like /admin/countries.old, and

2) copy my new /admin/countries.php file into its place.

This way, no changes to the menu structure have to be made. And, if the store owner ever chooses to uninstall the add-on, the new /admin/countries.php file would be deleted, and the renamed /admin/countries.old file would be renamed back to /admin/countries.php.

Thoughts?

M

If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get the latest community-supported responsive "Frozen" release here

Share this post

Link to post

Share on other sites

OK, I see. I think I'd (and definitely not saying this is the right way, but a way);

make new page new_countries.php

new file to add in link in localization

So far, no core changes. But you have a link to both countries pages in the box. So...this is the tricky bit;

make hook which places .js in the bottom of admin side, which
- removes the original countries.php link
- if they somehow manage to navigate to the original countries.php add in a message on that page under the page heading:

<divclass="secWarning">You have installed XYZ, use {link to new_countries.php} for localization purposes</div>

This is a signature that appears on all my posts. IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

Get the latest current code (community-supportedresponsive2.3.4.1BS Edge) here

Share this post

Link to post

Share on other sites

but there's the chance that the store owner has already made their own changes to /admin/includes/boxes/localization.php, so overwriting it would also not be a good choice.

They shouldn't have...if any addon requires shopowner to *manually* add code to a sidebox...the addon is outdated.
I think this system was introduced in 2.3.3 (or so), the ability to add links without amending files.

This is a signature that appears on all my posts. IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

Get the latest current code (community-supportedresponsive2.3.4.1BS Edge) here

new module for index_products which looks for assigned products and displays them appropriately [2 files]

All of the above is a long winded way of saying what you could do is leave the base functionality alone and instead have an extra page just doing the bits you want to add. Although this is 12 extra files, there is no touching of core code and the amount of time spent creating those 12 files is perhaps a few minutes more than trying to implement it all in admin/categories.php

Share this post

Link to post

Share on other sites

make hook which places .js in the bottom of admin side, which
- removes the original countries.php link
- if they somehow manage to navigate to the original countries.php add in a message on that page under the page heading:

This is what I was asking about ... if this was even possible. Way above my pay-grade, though.

I had considered creating a new table instead of adding additional fields to the existing Countries table, but thought it would require more work than it was worth. I may have to reconsider that.

But, since Admin is not modularized, there is no built-in way to install any new modules. The store owner would have to manually copy files, run something like phpMyAdmin to work on the database tables, etc. Definitely not a copy/one-click install/configure/go type of thing.

So, maybe this isn't something that really is suitable as an add-on. At least, not one that tries to conform to proper coding practices.

Thank you, though!

M

If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get the latest community-supported responsive "Frozen" release here