how to get your new tool added to the admin menu ... so I'm noting the process here.
Let's say that you have a new tool named new_tool.php that you want to plug into the Tools menu.
Most of the files that you distribute in the new_tool.zip file are identical with previous Zen Cart versions:
/YOUR_ADMIN/new_tool.php
/YOUR_ADMIN/includes/extra_datafiles/new_tool_filenames.php
/YOUR_ADMIN/includes/languages/english/extra_definitions/new_tool_name.php
/YOUR_ADMIN/includes/languages/english/new_tool.php
The file that you distribute to actually add new_tool.php to the Tools menu is different for v1.5.0 and later. In previous versions of Zen Cart,
you would have distributed a file named:
/YOUR_ADMIN/includes/boxes/extra_boxes/newtool_tools_dhtml.php that contained
$za_contents[] = array('text' => BOX_TOOLS_NEW_TOOL, 'link' => zen_href_link(FILENAME_NEW_TOOL, '', 'SSL'));
/YOUR_ADMIN/includes/functions/extra_functions/init_new_tool.php:
if (!defined('IS_ADMIN_FLAG')) { die('Illegal Access'); } //---- // If the installation supports admin-page registration (i.e. v1.5.0 and later), then // register the New Tools tool into the admin menu structure. // // NOTES: // 1) Once this file has run once and you see the Tools->New Tool link in the admin // menu structure, it is safe to delete this file (unless you have other functions that // are initialized in the file). // 2) If you have multiple items to add to the admin-level menus, then you should register each // of the pages here, just make sure that the "page key" is unique or a debug-log will be // generated! // if (function_exists('zen_register_admin_page')) { if (!zen_page_key_exists('toolsNewTool')) { zen_register_admin_page('toolsNewTool', 'BOX_TOOLS_NEW_TOOL', 'FILENAME_NEW_TOOL','' , 'tools', 'Y', 20); } }
- The value toolsNewTool is a (hopefully) unique value that identifies your new tool.
- The values BOX_TOOLS_NEW_TOOL and FILENAME_NEW_TOOL are defined within the other files within your toolset.
- The fourth parameter ('') has any parameters that your tool might require. (Rarely used.)
- The fifth parameter ('tools' in the example) identifies which of the high-level menu items your tool "attaches" to, one of: configuration, catalog, modules, customers, taxes, localization, reports, tools, gv, access, or extras.
- The sixth parameter ('Y') identifies whether ('Y') or not ('N') to display the page on the admin menu.
- The seventh parameter (20) is the sort order for the page, i.e. where it lives on the drop-down menu in relation to the sort order of others.
To remove your menu item, in the case a store-owner chooses to un-install your plugin, simply include a file in your distribution zip-file named /uninstall_new_page.sql that contains
DELETE FROM admin_pages WHERE page_key='toolsNewTool';
- Instead of distributing the init_new_tool.php file, you could include instructions to install using the Admin Access Management->
- Admin Page Registration tool.
- Set Page Key to toolsNewTool
- Set Page Name to BOX_TOOLS_NEW_TOOL
- Set Page File Name to FILENAME_NEW_TOOL
- Leave Page Parameters blank
- Select "Tools" from the Menu dropdown
- Check the "Show on Menu" box
- Set the Sort Order to 20
- If you don't see your newly added item, it's likely somewhere in the middle of the menu's dropdown list.
- Use 999 (or any other large number) for the sort order value if you want to ensure that your item is at the bottom of the menu's list.
- To reposition an item within one of the admin menus, use phpMyAdmin and browse the admin_pages table to find the added menu item and adjust its sort_order value as desired.
Thanks to Mega Moonshine for suggesting improvements made to this article on 2013-11-30!