Zen Cart admin menu
In Zen Cart, the admin menu is a set of features for administrators.
Contents
How to add items to the Admin menu (version: v1.5.x).
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:
Tool code
/YOUR_ADMIN/new_tool.php
- Contains the code that implements your new tool.
Filename definition
/YOUR_ADMIN/includes/extra_datafiles/new_tool_filenames.php
- filename definition for your new tool. Example:
-
define('FILENAME_NEW_TOOL', 'new_tool');
Menu item text
/YOUR_ADMIN/includes/languages/english/extra_definitions/new_tool_name.php
- the menu item text for your new tool. Example:
-
define('BOX_TOOLS_NEW_TOOL', 'New Tool');
Language-specific defines
/YOUR_ADMIN/includes/languages/english/new_tool.php
- the language-specific defines for your new tool.
- The filename of the language file must be the same as the filename of the tool itself.
Distributable file
For Zen Cart v1.5.0 and later, you will include a distributable file similar to the following:
/YOUR_ADMIN/includes/functions/extra_functions/init_new_tool.php
.
Containing code like this:
<code> 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); } } </code>
The value toolsNewTool
must be a 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
- Configuration
- Catalog
- Modules
- Customers
- Taxes
- Localization
- Reports
- Tools
- Gift Certificates
- Admin Access Management
- 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.
Removing the menu menu item:
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
Containing this code:
DELETE FROM admin_pages WHERE page_key='toolsNewTool';
Using the Admin Page Registration tool
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 menu.
- 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.